Small optimization ApierV1.SetTPDerivedChargers

This commit is contained in:
DanB
2017-05-22 11:08:27 +02:00
parent 81464d2364
commit f4a665d185
3 changed files with 45 additions and 42 deletions

View File

@@ -406,8 +406,9 @@ func (self *SQLStorage) SetTPDerivedChargers(sgs []*utils.TPDerivedChargers) err
m := make(map[string]bool)
tx := self.db.Begin()
for _, dCharger := range sgs {
if found, _ := m[dCharger.Direction]; !found {
m[dCharger.Direction] = true
dcKey := dCharger.GetDerivedChargersKey()
if found, _ := m[dcKey]; !found {
m[dcKey] = true
if err := tx.Delete(TpDerivedCharger{
Tpid: dCharger.TPid,
Direction: dCharger.Direction,