diff options
Diffstat (limited to 'string.c')
-rw-r--r-- | string.c | 9 |
1 files changed, 9 insertions, 0 deletions
@@ -1598,6 +1598,15 @@ rb_str_times(VALUE str, VALUE times) char *ptr2; int termlen; + if (times == INT2FIX(1)) { + return rb_str_dup(str); + } + if (times == INT2FIX(0)) { + str2 = str_alloc(rb_obj_class(str)); + rb_enc_copy(str2, str); + OBJ_INFECT(str2, str); + return str2; + } len = NUM2LONG(times); if (len < 0) { rb_raise(rb_eArgError, "negative argument"); |