summaryrefslogtreecommitdiffhomepage
path: root/src/string.c
diff options
context:
space:
mode:
authordearblue <[email protected]>2019-06-22 23:09:36 +0900
committerdearblue <[email protected]>2019-06-22 23:09:36 +0900
commit11e09dc5dbd6ddaabf145bbee62741f4191eca79 (patch)
tree663bb7c4e97141ff2f6729a2dc8b6a2a261e0e0c /src/string.c
parentec03e3f54af55af8c461a19b2f7cf0a984282997 (diff)
downloadmruby-11e09dc5dbd6ddaabf145bbee62741f4191eca79.tar.gz
mruby-11e09dc5dbd6ddaabf145bbee62741f4191eca79.zip
Fix the unnecessary `mrb_str_modify()` call
Now to be calls `mrb_str_modify()` only once when 2 or more characters.
Diffstat (limited to 'src/string.c')
-rw-r--r--src/string.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/string.c b/src/string.c
index 2cfdc337e..2d9d176d4 100644
--- a/src/string.c
+++ b/src/string.c
@@ -1710,11 +1710,13 @@ mrb_str_reverse_bang(mrb_state *mrb, mrb_value str)
str_reverse(p, p + clen - 1);
p += clen;
}
+ goto bytes;
}
#endif
- mrb_str_modify(mrb, s);
if (RSTR_LEN(s) > 1) {
+ mrb_str_modify(mrb, s);
+ bytes:
p = RSTR_PTR(s);
e = p + RSTR_LEN(s) - 1;
str_reverse(p, e);