summaryrefslogtreecommitdiff
path: root/tools.c
diff options
context:
space:
mode:
authorKlaus Schmidinger <vdr@tvdr.de>2005-05-26 11:41:33 +0200
committerKlaus Schmidinger <vdr@tvdr.de>2005-05-26 11:41:33 +0200
commit1855ab0ef3ff5ef220cbd3bc486b0c4d66063073 (patch)
tree0a651fb83e19f63f5acc96ba50b477e4b0f7b0ed /tools.c
parent373c69043ae352778974735460753d5e4f500789 (diff)
downloadvdr-1855ab0ef3ff5ef220cbd3bc486b0c4d66063073.tar.gz
vdr-1855ab0ef3ff5ef220cbd3bc486b0c4d66063073.tar.bz2
Introduced cListBase::count for better performance
Diffstat (limited to 'tools.c')
-rw-r--r--tools.c20
1 files changed, 7 insertions, 13 deletions
diff --git a/tools.c b/tools.c
index 075be185..9e1ea1d0 100644
--- a/tools.c
+++ b/tools.c
@@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
- * $Id: tools.c 1.92 2005/05/16 09:55:26 kls Exp $
+ * $Id: tools.c 1.93 2005/05/26 11:40:14 kls Exp $
*/
#include "tools.h"
@@ -932,6 +932,7 @@ int cListObject::Index(void) const
cListBase::cListBase(void)
{
objects = lastObject = NULL;
+ count = 0;
}
cListBase::~cListBase()
@@ -952,6 +953,7 @@ void cListBase::Add(cListObject *Object, cListObject *After)
objects = Object;
lastObject = Object;
}
+ count++;
}
void cListBase::Ins(cListObject *Object, cListObject *Before)
@@ -967,6 +969,7 @@ void cListBase::Ins(cListObject *Object, cListObject *Before)
lastObject = Object;
objects = Object;
}
+ count++;
}
void cListBase::Del(cListObject *Object, bool DeleteObject)
@@ -978,6 +981,7 @@ void cListBase::Del(cListObject *Object, bool DeleteObject)
Object->Unlink();
if (DeleteObject)
delete Object;
+ count--;
}
void cListBase::Move(int From, int To)
@@ -1017,6 +1021,7 @@ void cListBase::Clear(void)
objects = object;
}
objects = lastObject = NULL;
+ count = 0;
}
cListObject *cListBase::Get(int Index) const
@@ -1029,18 +1034,6 @@ cListObject *cListBase::Get(int Index) const
return object;
}
-int cListBase::Count(void) const
-{
- int n = 0;
- cListObject *object = objects;
-
- while (object) {
- n++;
- object = object->Next();
- }
- return n;
-}
-
static int CompareListObjects(const void *a, const void *b)
{
const cListObject *la = *(const cListObject **)a;
@@ -1062,6 +1055,7 @@ void cListBase::Sort(void)
objects = lastObject = NULL;
for (i = 0; i < n; i++) {
a[i]->Unlink();
+ count--;
Add(a[i]);
}
}