summaryrefslogtreecommitdiffhomepage
path: root/mrbgems/mruby-string-ext/src
diff options
context:
space:
mode:
authorFrederick John Milens III <[email protected]>2013-08-22 19:29:36 -0500
committerFrederick John Milens III <[email protected]>2013-08-22 19:29:36 -0500
commit2548569f60a9e64843f9da04cb497d268af33082 (patch)
tree3b767ac38c7831ea0234e05260fd7079348b1577 /mrbgems/mruby-string-ext/src
parent28211d677173c8279cfa8b89dd7df31ec30ee1c3 (diff)
downloadmruby-2548569f60a9e64843f9da04cb497d268af33082.tar.gz
mruby-2548569f60a9e64843f9da04cb497d268af33082.zip
Refactor of String#start_with? comparison logic.
Diffstat (limited to 'mrbgems/mruby-string-ext/src')
-rw-r--r--mrbgems/mruby-string-ext/src/string.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/mrbgems/mruby-string-ext/src/string.c b/mrbgems/mruby-string-ext/src/string.c
index 9763794f4..33ed3095b 100644
--- a/mrbgems/mruby-string-ext/src/string.c
+++ b/mrbgems/mruby-string-ext/src/string.c
@@ -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();
}
}