summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordrstein drstein@31f1291d-b8d6-0310-a050-a5561fc1590b <drstein drstein@31f1291d-b8d6-0310-a050-a5561fc1590b@5417fbe8-f217-4b02-8779-1006273d7864>2007-08-26 20:49:18 +0000
committerdrstein drstein@31f1291d-b8d6-0310-a050-a5561fc1590b <drstein drstein@31f1291d-b8d6-0310-a050-a5561fc1590b@5417fbe8-f217-4b02-8779-1006273d7864>2007-08-26 20:49:18 +0000
commit82015a606fad633d0e3360b46b08ec5ebd1b3b1b (patch)
tree8d66893333aad337c5d74a10d64469cfcef18197 /src
parent17946690bf20433876fa4392537940f4c31a4677 (diff)
BUILD : 1.7.19 (1268) BUGS : 662 NOTES : Optimized akick and badwords lists, provided by Viper.
git-svn-id: svn://svn.anope.org/anope/trunk@1269 31f1291d-b8d6-0310-a050-a5561fc1590b git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@987 5417fbe8-f217-4b02-8779-1006273d7864
Diffstat (limited to 'src')
-rw-r--r--src/core/bs_badwords.c10
-rw-r--r--src/core/cs_akick.c32
2 files changed, 27 insertions, 15 deletions
diff --git a/src/core/bs_badwords.c b/src/core/bs_badwords.c
index 7698d8cfc..3a0828db4 100644
--- a/src/core/bs_badwords.c
+++ b/src/core/bs_badwords.c
@@ -217,7 +217,15 @@ int do_badwords(User * u)
}
}
}
- ci->bwcount--;
+ /* After reordering only the entries at the end could still be empty.
+ * We ll free the places no longer in use... - Viper */
+ for (i = ci->bwcount - 1; i >= 0; i--) {
+ if (ci->badwords[i].in_use)
+ break;
+ ci->bwcount--;
+ }
+ ci->badwords =
+ srealloc(ci->badwords,sizeof(BadWord) * ci->bwcount);
}
} else if (stricmp(cmd, "LIST") == 0) {
diff --git a/src/core/cs_akick.c b/src/core/cs_akick.c
index 50faad99d..773388b8a 100644
--- a/src/core/cs_akick.c
+++ b/src/core/cs_akick.c
@@ -248,20 +248,15 @@ int do_akick(User * u)
}
}
- for (i = 0; i < ci->akickcount; i++) {
- if (!(ci->akick[i].flags & AK_USED))
- break;
- }
- if (i == ci->akickcount) {
- if (ci->akickcount >= CSAutokickMax) {
- notice_lang(s_ChanServ, u, CHAN_AKICK_REACHED_LIMIT,
- CSAutokickMax);
- return MOD_CONT;
- }
- ci->akickcount++;
- ci->akick =
- srealloc(ci->akick, sizeof(AutoKick) * ci->akickcount);
+ /* All entries should be in use so we don't have to go over
+ * the entire list. We simply add new entries at the end. */
+ if (ci->akickcount >= CSAutokickMax) {
+ notice_lang(s_ChanServ, u, CHAN_AKICK_REACHED_LIMIT, CSAutokickMax);
+ return MOD_CONT;
}
+ ci->akickcount++;
+ ci->akick =
+ srealloc(ci->akick, sizeof(AutoKick) * ci->akickcount);
akick = &ci->akick[i];
akick->flags = AK_USED;
if (nc) {
@@ -468,7 +463,16 @@ int do_akick(User * u)
}
}
}
- ci->akickcount--;
+ /* After reordering only the entries at the end could still be empty.
+ * We ll free the places no longer in use... - Viper */
+ for (i = ci->akickcount - 1; i >= 0; i--) {
+ if (ci->akick[i].flags & AK_USED)
+ break;
+
+ ci->akickcount--;
+ }
+ ci->akick =
+ srealloc(ci->akick,sizeof(AutoKick) * ci->akickcount);
}
} else if (stricmp(cmd, "LIST") == 0) {
int sent_header = 0;