mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
Refactor of String#start_with? comparison logic.
This commit is contained in:
@@ -117,12 +117,11 @@ mrb_str_start_with(mrb_state *mrb, mrb_value self)
|
||||
mrb_get_args(mrb, "*", &argv, &argc);
|
||||
|
||||
for (i = 0; i < argc; i++) {
|
||||
size_t len_l, len_r, len_cmp;
|
||||
size_t len_l, len_r;
|
||||
len_l = RSTRING_LEN(self);
|
||||
len_r = RSTRING_LEN(argv[i]);
|
||||
if (len_l >= len_r) {
|
||||
len_cmp = (len_l > len_r) ? len_r : len_l;
|
||||
if (memcmp(RSTRING_PTR(self), RSTRING_PTR(argv[i]), len_cmp) == 0) {
|
||||
if (memcmp(RSTRING_PTR(self), RSTRING_PTR(argv[i]), len_r) == 0) {
|
||||
return mrb_true_value();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user