diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2017-02-11 10:26:09 +0900 |
|---|---|---|
| committer | GitHub <[email protected]> | 2017-02-11 10:26:09 +0900 |
| commit | b36495bcb5a4f30144bc27c38167d02907ca8dc7 (patch) | |
| tree | 9a97ca0f35e20c5cc7109c16601f89c44a2a7c69 /src/string.c | |
| parent | c802cd07baf7132c5053defac883f0ee6b7967b7 (diff) | |
| parent | d1bc7caecaf337976351934d5910726106601bd9 (diff) | |
| download | mruby-b36495bcb5a4f30144bc27c38167d02907ca8dc7.tar.gz mruby-b36495bcb5a4f30144bc27c38167d02907ca8dc7.zip | |
Merge pull request #3449 from dabroz/fix-ljust-ruby
String#ljust and String#rjust reimplemented with optimized Ruby
Diffstat (limited to 'src/string.c')
| -rw-r--r-- | src/string.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/string.c b/src/string.c index c370e0723..2e8ebda32 100644 --- a/src/string.c +++ b/src/string.c @@ -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) { |
