Permalink
Browse files

Optimization for String#* for 1-byte strings

  • Loading branch information...
dabroz committed Feb 10, 2017
1 parent ac9d04f commit d1bc7caecaf337976351934d5910726106601bd9
Showing with 3 additions and 1 deletion.
  1. +3 −1 src/string.c
View
@@ -870,7 +870,9 @@ mrb_str_times(mrb_state *mrb, mrb_value self)
str2 = str_new(mrb, 0, len);
str_with_class(mrb, str2, self);
p = RSTR_PTR(str2);
if (len > 0) {
if (len == 1) {
memset(p, RSTRING_PTR(self)[0], len);
} else if (len > 0) {
n = RSTRING_LEN(self);
memcpy(p, RSTRING_PTR(self), n);
while (n <= len/2) {

0 comments on commit d1bc7ca

Please sign in to comment.