Explorar el Código

misc/cstring.h: simplify implementation of b_cstring_memchr() using the character iteration macro

ambrop7 hace 13 años
padre
commit
8cea86a1c1
Se han modificado 1 ficheros con 5 adiciones y 7 borrados
  1. 5 7
      misc/cstring.h

+ 5 - 7
misc/cstring.h

@@ -315,14 +315,12 @@ static int b_cstring_memchr (b_cstring cstr, size_t offset, size_t length, char
 {
     b_cstring_assert_range(cstr, offset, length);
     
-    B_CSTRING_LOOP_RANGE(cstr, offset, length, pos, chunk_data, chunk_length, {
-        for (size_t i = 0; i < chunk_length; i++) {
-            if (chunk_data[i] == ch) {
-                if (out_pos) {
-                    *out_pos = pos + i;
-                }
-                return 1;
+    B_CSTRING_LOOP_CHARS_RANGE(cstr, offset, length, cur_ch_pos, cur_ch, {
+        if (cur_ch == ch) {
+            if (out_pos) {
+                *out_pos = cur_ch_pos;
             }
+            return 1;
         }
     })