mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
string.c (mrb_memsearch_qs): reduce the scope of local variables
This commit is contained in:
+3
-1
@@ -477,15 +477,17 @@ mrb_memsearch_qs(const unsigned char *xs, mrb_int m, const unsigned char *ys, mr
|
||||
return -1;
|
||||
}
|
||||
else {
|
||||
const unsigned char *x = xs, *xe = xs + m;
|
||||
const unsigned char *y = ys;
|
||||
ptrdiff_t qstable[256];
|
||||
|
||||
/* Preprocessing */
|
||||
for (int i = 0; i < 256; i++)
|
||||
qstable[i] = m + 1;
|
||||
|
||||
const unsigned char *x = xs, *xe = xs + m;
|
||||
for (; x < xe; x++)
|
||||
qstable[*x] = xe - x;
|
||||
|
||||
/* Searching */
|
||||
for (; y + m <= ys + n; y += *(qstable + y[m])) {
|
||||
if (*xs == *y && memcmp(xs, y, m) == 0)
|
||||
|
||||
Reference in New Issue
Block a user