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

ChangeLog
lib/mbschr.c
modules/mbschr

index d1b135958c73e42d5a00bac9c19b6b6e6a681282..de7744f0efaac17465a02dd85fbac31915030b6d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 2023-07-18  Bruno Haible  <bruno@clisp.org>
 
+       mbschr: Optimize.
+       * lib/mbschr.c: Include mbuiterf.h instead of mbuiter.h.
+       (mbschr): Use mbuif_* macros instead of mbui_* macros.
+       * modules/mbschr (Depends-on): Add mbuiterf. Remove mbuiter.
+
        mbslen: Optimize.
        * lib/mbslen.c: Include mbuiterf.h instead of mbuiter.h.
        (mbslen): Use mbuif_* macros instead of mbui_* macros.
index 81323b4f9d8c4724a1a49abbf2d09348f0f41621..330e3f1c75c66f820e1abae78a946983e949a7fd 100644 (file)
@@ -20,7 +20,7 @@
 /* Specification.  */
 #include <string.h>
 
-#include "mbuiter.h"
+#include "mbuiterf.h"
 
 /* Locate the first single-byte character C in the character string STRING,
    and return a pointer to it.  Return NULL if C is not found in STRING.  */
@@ -33,17 +33,18 @@ mbschr (const char *string, int c)
          the faster unibyte loop can be used.  */
       && (unsigned char) c >= 0x30)
     {
-      mbui_iterator_t iter;
-
-      for (mbui_init (iter, string);; mbui_advance (iter))
+      mbuif_state_t state;
+      const char *iter;
+      for (mbuif_init (state), iter = string;; )
         {
-          if (!mbui_avail (iter))
+          if (!mbuif_avail (state, iter))
             goto notfound;
-          if (mb_len (mbui_cur (iter)) == 1
-              && (unsigned char) * mbui_cur_ptr (iter) == (unsigned char) c)
+          mbchar_t cur = mbuif_next (state, iter);
+          if (mb_len (cur) == 1 && (unsigned char) *iter == (unsigned char) c)
             break;
+          iter += mb_len (cur);
         }
-      return (char *) mbui_cur_ptr (iter);
+      return (char *) iter;
      notfound:
       return NULL;
     }
index e3382e08b48aaa21958e2748d0b7c5ba12353547..e99a3caf6cdb47e2c9777ebf6a5dc8c009de4914 100644 (file)
@@ -5,7 +5,7 @@ Files:
 lib/mbschr.c
 
 Depends-on:
-mbuiter
+mbuiterf
 string
 
 configure.ac: