From b9d090e1127343eae6c82b09eec307565f6e2892 Mon Sep 17 00:00:00 2001 From: satbaby Date: Mon, 16 May 2011 11:14:39 +0000 Subject: [PATCH] oops git-svn-id: file:///home/bas/coolstream_public_svn/THIRDPARTY/applications/neutrino-experimental@1477 e54a6e83-5905-42d5-8d5c-058d10e6a962 --- src/sectionsd/sectionsd.cpp | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/src/sectionsd/sectionsd.cpp b/src/sectionsd/sectionsd.cpp index 688761882..2b94d8aa6 100644 --- a/src/sectionsd/sectionsd.cpp +++ b/src/sectionsd/sectionsd.cpp @@ -784,7 +784,7 @@ static void addEvent(const SIevent &evt, const unsigned table_id, const time_t z dprintf("replacing event %016llx:%02x with %04x:%02x '%.40s'\n", si->second->uniqueKey(), si->second->table_id, evt.eventID, evt.table_id, evt.getName().c_str()); } - else if (already_exists && (evt.table_id == si->second->table_id && evt.version != si->second->version ) ) + else if (already_exists && ( evt.table_id == si->second->table_id && evt.version != si->second->version )) { //replace event if new version dprintf("replacing event version old 0x%02x new 0x%02x'\n", si->second->version, evt.version ); @@ -913,29 +913,35 @@ 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; - if ((*x)->times.begin()->startzeit != start_time) + if ((*x)->times.begin()->startzeit > start_time) continue; + /* iterating backwards: if the starttime of the stored events + * is earlier than the new one, we'll never find an identical one + * => bail out */ + if ((*x)->times.begin()->startzeit < start_time) + break; + /* here we have (*x)->times.begin()->startzeit == start_time */ if ((*x)->table_id < e->table_id) { /* if we already have an event with the same start time but a lower