variable.c: improve binary search logic in bsearch_idx

Co-authored-by: Gemini <gemini@google.com>
This commit is contained in:
Yukihiro "Matz" Matsumoto
2025-07-25 13:21:00 +09:00
parent 50072c71ab
commit 8cd64f6e37
+1 -1
View File
@@ -88,7 +88,7 @@ bsearch_idx(mrb_sym *keys, int size, mrb_sym target) {
n -= half;
}
/* Final adjustment: if the remaining element is still less than target, advance by one */
return (int)(p - keys) + (keys[0] < target);
return (int)(p - keys) + (p[0] < target);
}
/* Set (insert or update) the value for `sym` in the instance variable table using branch-free search. */