]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Optimisation cleanup of fake_auth
authoramosjeffries <>
Tue, 4 Mar 2008 19:08:20 +0000 (19:08 +0000)
committeramosjeffries <>
Tue, 4 Mar 2008 19:08:20 +0000 (19:08 +0000)
strlen() is expensive (particularly on large buffers) and is only needed
once here.

helpers/ntlm_auth/fakeauth/fakeauth_auth.c

index bd8e7e44ace603b862cc7ee616379114df03efdf..eb4cb5183825fdc904fcd69221ff1d8275271a83 100644 (file)
@@ -369,6 +369,7 @@ int
 main(int argc, char *argv[])
 {
     char buf[BUFFER_SIZE];
+    int buflen = 0;
     char user[256], *p, *decoded = NULL;
     struct ntlm_challenge chal;
     struct ntlm_negotiate *nego;
@@ -390,9 +391,10 @@ main(int argc, char *argv[])
 
        if ((p = strchr(buf, '\n')) != NULL)
            *p = '\0';          /* strip \n */
-       if (strlen(buf) > 3)
+        buflen = strlen(buf);   /* keep this so we only scan the buffer for \0 once per loop */
+       if (buflen > 3)
            decoded = base64_decode(buf + 3);
-       if ((strlen(buf) > 3) && NTLM_packet_debug_enabled) {
+       if (buflen > 3 && NTLM_packet_debug_enabled) {
            strncpy(helper_command, buf, 2);
            helper_command[2] = '\0';
            debug("Got '%s' from Squid with data:\n", helper_command);
@@ -401,7 +403,7 @@ main(int argc, char *argv[])
            debug("Got '%s' from Squid\n", buf);
 
        if (strncasecmp(buf, "YR", 2) == 0) {
-           if (strlen(buf) > 3) {
+           if(buflen > 3) {
                nego = (struct ntlm_negotiate *) decoded;
                ntlmMakeChallenge(&chal, nego->flags);
            } else