From 7d42c4fc6d607ea3f1da3142083fba136c6db9c7 Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Sun, 15 May 2011 23:53:27 +0000 Subject: [PATCH] sectionsd: optimize the slow_addevent case a bit more git-svn-id: file:///home/bas/coolstream_public_svn/THIRDPARTY/applications/neutrino-experimental@1475 e54a6e83-5905-42d5-8d5c-058d10e6a962 Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/2fbbef4e34a1ce1739c6d40e66866615deca4659 Author: Stefan Seyfried Date: 2011-05-16 (Mon, 16 May 2011) ------------------ This commit was generated by Migit --- src/sectionsd/sectionsd.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/sectionsd/sectionsd.cpp b/src/sectionsd/sectionsd.cpp index 2f75b8d17..44a181dfc 100644 --- a/src/sectionsd/sectionsd.cpp +++ b/src/sectionsd/sectionsd.cpp @@ -913,24 +913,24 @@ if (slow_addevent) event_id_t e_key = e->uniqueKey(); t_channel_id e_chid = e->get_channel_id(); time_t start_time = e->times.begin()->startzeit; - bool found = false; - /* experiments have shown that iterating backwards here is much faster */ + /* create an event that's surely behind the one to check in the sort order */ + SIevent *fptr = new SIevent(evt); + fptr->eventID = 0xFFFF; /* lowest order sort criteria is eventID */ + SIeventPtr f(fptr); + /* returns an iterator that's behind 'f' */ MySIeventsOrderServiceUniqueKeyFirstStartTimeEventUniqueKey::iterator x = - mySIeventsOrderServiceUniqueKeyFirstStartTimeEventUniqueKey.end(); + mySIeventsOrderServiceUniqueKeyFirstStartTimeEventUniqueKey.upper_bound(f); + /* the first decrement of the iterator gives us an event that's a potential + * match *or* from a different channel, then no event for this channel is stored */ while (x != mySIeventsOrderServiceUniqueKeyFirstStartTimeEventUniqueKey.begin()) { x--; if ((*x)->get_channel_id() != e_chid) - { - /* sorted by service id first */ - if (found) - break; - } + break; else { event_id_t x_key = (*x)->uniqueKey(); - found = true; /* do we need this check? */ if (x_key == e_key) continue;