Reduce number of branches in register_user().
authorMichael Poole <mdpoole@troilus.org>
Mon, 30 May 2005 13:16:57 +0000 (13:16 +0000)
committerMichael Poole <mdpoole@troilus.org>
Mon, 30 May 2005 13:16:57 +0000 (13:16 +0000)
git-svn-id: file:///home/klmitch/undernet-ircu/undernet-ircu-svn/ircu2/trunk@1412 c9e4aea6-c8fd-4c43-8297-357d70d61c8c

ChangeLog
ircd/s_user.c

index 13bb5e5f16a50bfcbf226e480ec80168fb6e904b..1951e75337c081553b648ebc9d155304e9f8330e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -6,6 +6,9 @@
        * ircd/m_endburst.c (ms_endofburst): Avoid dereferencing 'chan'
        after it may be freed (in sub1_from_channel).
 
+       * ircd/s_user.c (register_user): Rearrange code to reduce number
+       of "if (MyConnect(sptr))" checks.
+
 2005-05-12  Michael Poole <mdpoole@troilus.org>
 
        * configure.in: Do not try to outsmart the default CFLAGS.
index ed9ccd61de5d07dd5b3322fc6f96029ca890145b..285acb64f8a2d154b0e44230faabc69f5853f64d 100644 (file)
@@ -564,19 +564,8 @@ int register_user(struct Client *cptr, struct Client *sptr,
       return exit_client(cptr, sptr, &me, "USER: Bad username");
     }
     Count_unknownbecomesclient(sptr, UserStats);
-  }
-  else {
-    ircd_strncpy(user->username, username, USERLEN);
-    Count_newremoteclient(UserStats, user->server);
-  }
-  SetUser(sptr);
 
-  if (IsInvisible(sptr))
-    ++UserStats.inv_clients;
-  if (IsOper(sptr))
-    ++UserStats.opers;
-
-  if (MyConnect(sptr)) {
+    SetUser(sptr);
     cli_handler(sptr) = CLIENT_HANDLER;
     release_dns_reply(sptr);
     SetLocalNumNick(sptr);
@@ -597,7 +586,6 @@ int register_user(struct Client *cptr, struct Client *sptr,
     m_lusers(sptr, sptr, 1, parv);
     update_load();
     motd_signon(sptr);
-/*      nextping = CurrentTime; */
     if (cli_snomask(sptr) & SNO_NOISY)
       set_snomask(sptr, cli_snomask(sptr) & SNO_NOISY, SNO_ADD);
     if (feature_bool(FEAT_CONNEXIT_NOTICES))
@@ -626,7 +614,6 @@ int register_user(struct Client *cptr, struct Client *sptr,
         break;
       case 'i':
         SetInvisible(sptr);
-        ++UserStats.inv_clients;
         break;
       case 'd':
         SetDeaf(sptr);
@@ -638,11 +625,12 @@ int register_user(struct Client *cptr, struct Client *sptr,
       }
     }
   }
-  else
-    /* if (IsServer(cptr)) */
-  {
+  else {
     struct Client *acptr;
 
+    ircd_strncpy(user->username, username, USERLEN);
+    Count_newremoteclient(UserStats, user->server);
+
     acptr = user->server;
     if (cli_from(acptr) != cli_from(sptr))
     {
@@ -661,7 +649,7 @@ int register_user(struct Client *cptr, struct Client *sptr,
      * FIXME: This can be sped up - its stupid to check it for
      * every NICK message in a burst again  --Run.
      */
-    for (acptr = user->server; acptr != &me; acptr = cli_serv(acptr)->up)
+    for (; acptr != &me; acptr = cli_serv(acptr)->up)
     {
       if (IsBurst(acptr) || Protocol(acptr) < 10)
         break;
@@ -675,7 +663,14 @@ int register_user(struct Client *cptr, struct Client *sptr,
                     sptr, cli_name(&me));
       return exit_client(cptr, sptr, &me,"Too many connections from your host -- throttled");
     }
+    SetUser(sptr);
   }
+
+  if (IsInvisible(sptr))
+    ++UserStats.inv_clients;
+  if (IsOper(sptr))
+    ++UserStats.opers;
+
   tmpstr = umode_str(sptr);
   /* Send full IP address to IPv6-grokking servers. */
   sendcmdto_flag_serv_butone(user->server, CMD_NICK, cptr,