1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Append subsec part instead of creating new string

This commit is contained in:
Nobuyoshi Nakada 2020-06-03 12:42:47 +09:00
parent 160511d851
commit ee35a4dad3
No known key found for this signature in database
GPG key ID: 7CD2805BFA3770C6

2
time.c
View file

@ -4145,7 +4145,7 @@ time_inspect(VALUE time)
}
else if (FIXNUM_P(subsec) && FIX2LONG(subsec) < TIME_SCALE) {
long len;
str = rb_enc_sprintf(rb_usascii_encoding(), "%"PRIsVALUE".%09ld", str, FIX2LONG(subsec));
rb_str_catf(str, ".%09ld", FIX2LONG(subsec));
for (len=RSTRING_LEN(str); RSTRING_PTR(str)[len-1] == '0' && len > 0; len--)
;
rb_str_resize(str, len);