mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
Merge pull request #3067 from ksss/use-memchr
Use memchr for performance
This commit is contained in:
+6
-6
@@ -352,12 +352,12 @@ mrb_memsearch(const void *x0, mrb_int m, const void *y0, mrb_int n)
|
||||
return 0;
|
||||
}
|
||||
else if (m == 1) {
|
||||
const unsigned char *ys = y, *ye = ys + n;
|
||||
for (; y < ye; ++y) {
|
||||
if (*x == *y)
|
||||
return y - ys;
|
||||
}
|
||||
return -1;
|
||||
const unsigned char *ys = memchr(y, *x, n);
|
||||
|
||||
if (ys)
|
||||
return ys - y;
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
return mrb_memsearch_qs((const unsigned char *)x0, m, (const unsigned char *)y0, n);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user