Small optimization.
authorBruno Haible <bruno@clisp.org>
Sun, 11 Feb 2007 22:30:04 +0000 (22:30 +0000)
committerBruno Haible <bruno@clisp.org>
Sun, 11 Feb 2007 22:30:04 +0000 (22:30 +0000)
ChangeLog
lib/mbscspn.c

index bfe4e299e6bbd4c77f902866c65e74810d222372..b379469aff6e2942e6b03f0178df27ef37c15833 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2007-02-11  Bruno Haible  <bruno@clisp.org>
 
+       * lib/mbscspn.c (mbscspn): Remove unnecessary strlen call and
+       unneeded cast.
+
        * modules/mbscspn-tests: New file.
        * tests/test-mbscspn.sh: New file.
        * tests/test-mbscspn.c: New file.
index 30153a14ca59be05134fe13b3f981aaf71927687..543a121fa7454e352f7e906dffd44b70f8730366 100644 (file)
@@ -50,8 +50,8 @@ mbscspn (const char *string, const char *accept)
        {
          if (mb_len (mbui_cur (iter)) == 1)
            {
-             if (mbschr (accept, (unsigned char) * mbui_cur_ptr (iter)))
-               return mbui_cur_ptr (iter) - string;
+             if (mbschr (accept, * mbui_cur_ptr (iter)))
+               goto found;
            }
          else
            {
@@ -61,10 +61,11 @@ mbscspn (const char *string, const char *accept)
                   mbui_avail (aiter);
                   mbui_advance (aiter))
                if (mb_equal (mbui_cur (aiter), mbui_cur (iter)))
-                 return mbui_cur_ptr (iter) - string;
+                 goto found;
            }
        }
-      return strlen (string);
+     found:
+      return mbui_cur_ptr (iter) - string;
     }
   else
 #endif