From 1e025579511481e2c8d2db57d54a193e6a5a25fc Mon Sep 17 00:00:00 2001 From: Richard Fuchs Date: Tue, 6 May 2025 13:11:37 -0400 Subject: [PATCH] MT#62181 RegisterCache: use entries_by_time We can now use the sets to iterate the bindings in order of their expiry and exit the loop when we encounter the first one with an expiry in the future. Change-Id: I093bea9807b4a432ac965b402394edc43eef5a1f --- apps/sbc/RegisterCache.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/apps/sbc/RegisterCache.cpp b/apps/sbc/RegisterCache.cpp index d54043cc..be4a5dcf 100644 --- a/apps/sbc/RegisterCache.cpp +++ b/apps/sbc/RegisterCache.cpp @@ -41,8 +41,14 @@ void AorHash::dump_elmt(const string& aor, void AorHash::gbc(long int now, list& alias_list) { - for(auto it = begin(); it != end();) { + for (auto set_it = entries_by_time.begin(); set_it != entries_by_time.end();) { + iterator it = *set_it; + auto next = set_it; + next++; + AorEntry& aor_e = it->second; + if (aor_e.get_lowest_expire() > now) + break; for (AorEntry::iterator reg_it = aor_e.begin(); reg_it != aor_e.end();) { @@ -63,13 +69,11 @@ void AorHash::gbc(long int now, } reg_it++; } - if(it->second.empty()) { + if (aor_e.empty()) { DBG("delete empty AOR: '%s'", it->first.c_str()); - auto del_it = it++; - erase(del_it); - continue; + erase(it); } - it++; + set_it = next; } }