1
0
mirror of https://github.com/VDR4Arch/vdr.git synced 2023-10-10 13:36:52 +02:00

Speeded up deleting duplicate channels

This commit is contained in:
Klaus Schmidinger 2005-05-29 10:33:21 +02:00
parent bce13e7148
commit 3b69903d23
2 changed files with 32 additions and 16 deletions

View File

@ -3513,7 +3513,7 @@ Video Disk Recorder Revision History
- Fixed a wrong inheritance in libsi's SubtitlingDescriptor::Subtitling (thanks to - Fixed a wrong inheritance in libsi's SubtitlingDescriptor::Subtitling (thanks to
Marco Schlüßler). Marco Schlüßler).
2005-05-28: Version 1.3.25 2005-05-29: Version 1.3.25
- Updated the Estonian OSD texts (thanks to Arthur Konovalov). - Updated the Estonian OSD texts (thanks to Arthur Konovalov).
- Some cable providers don't mark short channel names according to the standard, - Some cable providers don't mark short channel names according to the standard,
@ -3572,3 +3572,4 @@ Video Disk Recorder Revision History
a patch from Georg Acher). a patch from Georg Acher).
- Avoiding unnecessary calls to getLength() in libsi/si.c, and avoiding the - Avoiding unnecessary calls to getLength() in libsi/si.c, and avoiding the
'& 0xff' in CRC32::crc32() of libsi/util.c (thanks to Georg Acher). '& 0xff' in CRC32::crc32() of libsi/util.c (thanks to Georg Acher).
- Speeded up deleting duplicate channels.

View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and * See the main source file 'vdr.c' for copyright information and
* how to reach the author. * how to reach the author.
* *
* $Id: channels.c 1.41 2005/05/28 13:55:57 kls Exp $ * $Id: channels.c 1.42 2005/05/29 10:32:38 kls Exp $
*/ */
#include "channels.h" #include "channels.h"
@ -804,6 +804,22 @@ bool cChannel::Save(FILE *f)
return fprintf(f, "%s", *ToText()) > 0; return fprintf(f, "%s", *ToText()) > 0;
} }
// -- cChannelSorter ---------------------------------------------------------
class cChannelSorter : public cListObject {
public:
cChannel *channel;
tChannelID channelID;
cChannelSorter(cChannel *Channel) {
channel = Channel;
channelID = channel->GetChannelID();
}
virtual int Compare(const cListObject &ListObject) const {
cChannelSorter *cs = (cChannelSorter *)&ListObject;
return memcmp(&channelID, &cs->channelID, sizeof(channelID));
}
};
// -- cChannels -------------------------------------------------------------- // -- cChannels --------------------------------------------------------------
cChannels Channels; cChannels Channels;
@ -816,21 +832,20 @@ cChannels::cChannels(void)
void cChannels::DeleteDuplicateChannels(void) void cChannels::DeleteDuplicateChannels(void)
{ {
cList<cChannelSorter> ChannelSorter;
for (cChannel *channel = First(); channel; channel = Next(channel)) { for (cChannel *channel = First(); channel; channel = Next(channel)) {
if (!channel->GroupSep()) { if (!channel->GroupSep())
tChannelID ChannelID = channel->GetChannelID(); ChannelSorter.Add(new cChannelSorter(channel));
cChannel *other = Next(channel);
while (other) {
cChannel *d = NULL;
if (!other->GroupSep() && other->GetChannelID() == ChannelID)
d = other;
other = Next(other);
if (d) {
dsyslog("deleting duplicate channel %s", *d->ToText());
Del(d);
}
} }
ChannelSorter.Sort();
cChannelSorter *cs = ChannelSorter.First();
while (cs) {
cChannelSorter *next = ChannelSorter.Next(cs);
if (next && cs->channelID == next->channelID) {
dsyslog("deleting duplicate channel %s", *next->channel->ToText());
Del(next->channel);
} }
cs = next;
} }
} }