some memory profiling and optimization

This commit is contained in:
Radu Ioan Fericean
2013-12-14 15:20:58 +02:00
parent 237508e590
commit 5a929dfeb0
3 changed files with 20 additions and 21 deletions

View File

@@ -266,17 +266,13 @@ func (cd *CallDescriptor) addRatingInfos(ris RatingInfos) bool {
return true
}
/*
Constructs the key for the storage lookup.
The prefixLen is limiting the length of the destination prefix.
*/
// Constructs the key for the storage lookup.
// The prefixLen is limiting the length of the destination prefix.
func (cd *CallDescriptor) GetKey(subject string) string {
return fmt.Sprintf("%s:%s:%s:%s", cd.Direction, cd.Tenant, cd.TOR, subject)
}
/*
Splits the received timespan into sub time spans according to the activation periods intervals.
*/
// Splits the received timespan into sub time spans according to the activation periods intervals.
func (cd *CallDescriptor) splitInTimeSpans(firstSpan *TimeSpan) (timespans []*TimeSpan) {
if firstSpan == nil {
firstSpan = &TimeSpan{TimeStart: cd.TimeStart, TimeEnd: cd.TimeEnd, CallDuration: cd.CallDuration}

View File

@@ -40,15 +40,16 @@ func (rpr *RPRate) Equal(orpr *RPRate) bool {
type RPRateList []*RPRate
func (rp *RatingPlan) RateIntervalList(dId string) (ril RateIntervalList) {
for _, rpr := range rp.DestinationRates[dId] {
ril = append(ril, &RateInterval{
func (rp *RatingPlan) RateIntervalList(dId string) RateIntervalList {
ril := make(RateIntervalList, len(rp.DestinationRates[dId]))
for i, rpr := range rp.DestinationRates[dId] {
ril[i] = &RateInterval{
Timing: rp.Timings[rpr.Timing],
Rating: rp.Ratings[rpr.Rating],
Weight: rpr.Weight,
})
}
}
return
return ril
}
/*