From d66eba77c272b55b39f70eac48f616f5692590c5 Mon Sep 17 00:00:00 2001 From: Klaus Schmidinger Date: Sat, 23 Jun 2007 13:24:00 +0200 Subject: Improved performance of the SVDRP commands LSTC and CHAN when used with a channel name --- HISTORY | 2 ++ svdrp.c | 56 ++++++++++++++++++++++---------------------------------- 2 files changed, 24 insertions(+), 34 deletions(-) diff --git a/HISTORY b/HISTORY index b538aa7f..f4e61dd5 100644 --- a/HISTORY +++ b/HISTORY @@ -5271,3 +5271,5 @@ Video Disk Recorder Revision History to Andreas Mair). - Added full weekday names to i18n.c for plugins to use (thanks to Patrice Staudt). - Fixed stripping i18n stuff from font names (reported by Anssi Hannula). +- Improved performance of the SVDRP commands LSTC and CHAN when used with a + channel name. diff --git a/svdrp.c b/svdrp.c index 96bc3836..3694ebb8 100644 --- a/svdrp.c +++ b/svdrp.c @@ -10,7 +10,7 @@ * and interact with the Video Disk Recorder - or write a full featured * graphical interface that sits on top of an SVDRP connection. * - * $Id: svdrp.c 1.101 2007/04/30 12:41:07 kls Exp $ + * $Id: svdrp.c 1.102 2007/06/23 13:14:59 kls Exp $ */ #include "svdrp.h" @@ -497,14 +497,14 @@ void cSVDRP::CmdCHAN(const char *Option) if (channel) n = channel->Number(); else { - int i = 1; - while ((channel = Channels.GetByNumber(i, 1)) != NULL) { - if (strcasecmp(channel->Name(), Option) == 0) { - n = channel->Number(); - break; - } - i = channel->Number() + 1; - } + for (cChannel *channel = Channels.First(); channel; channel = Channels.Next(channel)) { + if (!channel->GroupSep()) { + if (strcasecmp(channel->Name(), Option) == 0) { + n = channel->Number(); + break; + } + } + } } } if (n < 0) { @@ -871,23 +871,16 @@ void cSVDRP::CmdLSTC(const char *Option) Reply(501, "Channel \"%s\" not defined", Option); } else { - int i = 1; cChannel *next = NULL; - while (i <= Channels.MaxNumber()) { - cChannel *channel = Channels.GetByNumber(i, 1); - if (channel) { - if (strcasestr(channel->Name(), Option)) { - if (next) - Reply(-250, "%d %s", next->Number(), *next->ToText()); - next = channel; - } - } - else { - Reply(501, "Channel \"%d\" not found", i); - return; - } - i = channel->Number() + 1; - } + for (cChannel *channel = Channels.First(); channel; channel = Channels.Next(channel)) { + if (!channel->GroupSep()) { + if (strcasestr(channel->Name(), Option)) { + if (next) + Reply(-250, "%d %s", next->Number(), *next->ToText()); + next = channel; + } + } + } if (next) Reply(250, "%d %s", next->Number(), *next->ToText()); else @@ -895,15 +888,10 @@ void cSVDRP::CmdLSTC(const char *Option) } } else if (Channels.MaxNumber() >= 1) { - int i = 1; - while (i <= Channels.MaxNumber()) { - cChannel *channel = Channels.GetByNumber(i, 1); - if (channel) - Reply(channel->Number() < Channels.MaxNumber() ? -250 : 250, "%d %s", channel->Number(), *channel->ToText()); - else - Reply(501, "Channel \"%d\" not found", i); - i = channel->Number() + 1; - } + for (cChannel *channel = Channels.First(); channel; channel = Channels.Next(channel)) { + if (!channel->GroupSep()) + Reply(channel->Number() < Channels.MaxNumber() ? -250 : 250, "%d %s", channel->Number(), *channel->ToText()); + } } else Reply(550, "No channels defined"); -- cgit v1.2.3