]> Savannah Git Hosting - gnulib.git/commitdiff
mbspbrk: Optimize.
authorBruno Haible <bruno@clisp.org>
Tue, 18 Jul 2023 11:43:38 +0000 (13:43 +0200)
committerBruno Haible <bruno@clisp.org>
Tue, 18 Jul 2023 11:43:38 +0000 (13:43 +0200)
* lib/mbspbrk.c: Include mbuiterf.h instead of mbuiter.h.
(mbspbrk): Use mbuif_* macros instead of mbui_* macros.
* modules/mbspbrk (Depends-on): Add mbuiterf. Remove mbuiter.

ChangeLog
lib/mbspbrk.c
modules/mbspbrk

index ec0fa50d61a85e7327bb3d288e204f8c81e2c38e..31ab6508b059a4891f6c4232ad8d6fa30aa13c28 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 2023-07-18  Bruno Haible  <bruno@clisp.org>
 
+       mbspbrk: Optimize.
+       * lib/mbspbrk.c: Include mbuiterf.h instead of mbuiter.h.
+       (mbspbrk): Use mbuif_* macros instead of mbui_* macros.
+       * modules/mbspbrk (Depends-on): Add mbuiterf. Remove mbuiter.
+
        mbspcasecmp: Optimize.
        * lib/mbspcasecmp.c: Include mbuiterf.h instead of mbuiter.h.
        (mbspcasecmp): Use mbuif_* macros instead of mbui_* macros.
index 6132ec14894cf47e6af903183c46fbe2c245d504..9482eb00cb8643f227acabad380530308a75c3da 100644 (file)
@@ -20,7 +20,7 @@
 /* Specification.  */
 #include <string.h>
 
-#include "mbuiter.h"
+#include "mbuiterf.h"
 
 /* Find the first occurrence in the character string STRING of any character
    in the character string ACCEPT.  Return the pointer to it, or NULL if none
@@ -36,25 +36,30 @@ mbspbrk (const char *string, const char *accept)
   /* General case.  */
   if (MB_CUR_MAX > 1)
     {
-      mbui_iterator_t iter;
-
-      for (mbui_init (iter, string); mbui_avail (iter); mbui_advance (iter))
+      mbuif_state_t state;
+      const char *iter;
+      for (mbuif_init (state), iter = string; mbuif_avail (state, iter); )
         {
-          if (mb_len (mbui_cur (iter)) == 1)
+          mbchar_t cur = mbuif_next (state, iter);
+          if (mb_len (cur) == 1)
             {
-              if (mbschr (accept, * mbui_cur_ptr (iter)))
-                return (char *) mbui_cur_ptr (iter);
+              if (mbschr (accept, *iter))
+                return (char *) iter;
             }
           else
             {
-              mbui_iterator_t aiter;
-
-              for (mbui_init (aiter, accept);
-                   mbui_avail (aiter);
-                   mbui_advance (aiter))
-                if (mb_equal (mbui_cur (aiter), mbui_cur (iter)))
-                  return (char *) mbui_cur_ptr (iter);
+              mbuif_state_t astate;
+              const char *aiter;
+              for (mbuif_init (astate), aiter = accept;
+                   mbuif_avail (astate, aiter); )
+                {
+                  mbchar_t acur = mbuif_next (astate, aiter);
+                  if (mb_equal (acur, cur))
+                    return (char *) iter;
+                  aiter += mb_len (acur);
+                }
             }
+          iter += mb_len (cur);
         }
       return NULL;
     }
index 28417213125bb257fdac642f79f27869b184f044..158f55caa8b016cf6a740783e854ab6a69e1ef69 100644 (file)
@@ -5,7 +5,7 @@ Files:
 lib/mbspbrk.c
 
 Depends-on:
-mbuiter
+mbuiterf
 string
 mbschr
 strpbrk