From 2385f7b944bb22acd85e6c089e509880a45a2cb1 Mon Sep 17 00:00:00 2001 From: Luke Bratch Date: Wed, 2 Oct 2019 19:37:16 +0100 Subject: Try to make removenickfromallchannels() much faster when another user QUITs by ignoring unused channel indexes. --- TODO | 2 -- functions.c | 4 ++++ message.c | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/TODO b/TODO index a74bd7d..2407007 100644 --- a/TODO +++ b/TODO @@ -7,5 +7,3 @@ Add a make install/uninstall/etc., add an "INSTALL" file, include a dependency l macOS compiler may need limits.h included in structures.h. replaymode = "lastspoke" causes huge amounts of spam from extractnickfromprefix() and friends in full debug mode. - -Very slow processing of removenickfromallchannels() when another user QUITs (sometimes). diff --git a/functions.c b/functions.c index 730819f..c5e3cdc 100644 --- a/functions.c +++ b/functions.c @@ -1432,6 +1432,10 @@ int removenickfromallchannels(char *nickuserhost, struct channel *channels) { // Go through all channels and remove nick if present for (int i = 0; i < MAXCHANNELS; i++) { + // Don't bother checking this channel index if it isn't used + if (!channels[i].name[0]) { + continue; + } // Go through all nicks in channel for (int j = 0; j < MAXCHANNICKS; j++) { // Remove the nick from the channel if present diff --git a/message.c b/message.c index a187655..a2c16e4 100644 --- a/message.c +++ b/message.c @@ -267,7 +267,7 @@ int processservermessage(SSL *server_ssl, char *str, struct client *clients, int if (strncmp(tokens[1], "QUIT", strlen(tokens[1])) == 0) { debugprint(DEBUG_FULL, "Server QUIT found and it is: %s with length %zd! Next token is '%s'.\n", tokens[0], strlen(tokens[0]), tokens[2]); - // And then send to all clients + // Tell all clients sendtoallclients(clients, str, sourcefd, settings); // Write to replay log if replay logging enabled -- cgit v1.2.3