This commit is contained in:
DanB
2014-11-28 11:48:18 +01:00
2 changed files with 5 additions and 11 deletions

View File

@@ -43,10 +43,7 @@ func (cs cacheDoubleStore) Append(key string, value interface{}) {
} else {
elements = make(map[interface{}]struct{})
}
// check if the val is already present
if _, found := elements[value]; !found {
elements[value] = struct{}{}
}
elements[value] = struct{}{}
cache.Put(key, elements)
}
@@ -82,8 +79,8 @@ func (cs cacheDoubleStore) DeletePrefix(prefix string) {
}
func (cs cacheDoubleStore) CountEntriesForPrefix(prefix string) int {
if _, ok := cs[prefix]; ok {
return len(cs[prefix])
if m, ok := cs[prefix]; ok {
return len(m)
}
return 0
}
@@ -135,10 +132,7 @@ func (cs cacheSimpleStore) Append(key string, value interface{}) {
} else {
elements = make(map[interface{}]struct{})
}
// check if the val is already present
if _, found := elements[value]; !found {
elements[value] = struct{}{}
}
elements[value] = struct{}{}
cache.Put(key, elements)
}

View File

@@ -128,7 +128,7 @@ func (rp *RatingProfile) GetRatingPlansForPrefix(cd *CallDescriptor) (err error)
for _, p := range utils.SplitPrefix(cd.Destination, MIN_PREFIX_MATCH) {
if x, err := cache2go.GetCached(DESTINATION_PREFIX + p); err == nil {
destIds := x.(map[interface{}]struct{})
for idId, _ := range destIds {
for idId := range destIds {
dId := idId.(string)
if _, ok := rpl.DestinationRates[dId]; ok {
rps = rpl.RateIntervalList(dId)