1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
ruby--ruby/test/-ext-
John Hawthorn 04bc4c0662 Resize capacity for fstring
When a string is #frozen, it's capacity is resized to fit (if it is much
larger), since we know it will no longer be mutated.

    > puts ObjectSpace.dump(String.new("a"*30, capacity: 1000))
    {"type":"STRING", "class":"0x7feaf00b7bf0", "bytesize":30, "capacity":1000, "value":"...
    > puts ObjectSpace.dump(String.new("a"*30, capacity: 1000).freeze)
    {"type":"STRING", "class":"0x7feaf00b7bf0", "frozen":true, "bytesize":30, "value":"...

(ObjectSpace.dump doesn't show capacity if capacity is equal to bytesize)

Previously, if we dedup into an fstring, using String#-@, capacity would
not be reduced.

    > puts ObjectSpace.dump(-String.new("a"*30, capacity: 1000))
    {"type":"STRING", "class":"0x7feaf00b7bf0", "frozen":true, "fstring":true, "bytesize":30, "capacity":1000, "value":"...

This commit makes rb_fstring call rb_str_resize, the same as
rb_str_freeze does.

Closes: https://github.com/ruby/ruby/pull/2256
2019-06-26 15:01:48 +09:00
..
arith_seq
array
bignum
bug_reporter
class
debug Adjust indent 2019-05-10 22:00:22 +09:00
exception
file
float
funcall
gvl
hash
integer numeric.c: fix infinite loop 2019-03-11 01:37:16 +00:00
iseq_load
iter Ignore warnings about argument prefix with operator symbol. 2019-06-01 15:20:21 +03:00
load
marshal
method
num2int
path_to_class
popen_deadlock
postponed_job
proc
rational
st
string Resize capacity for fstring 2019-06-26 15:01:48 +09:00
struct
symbol Get rid of error with frozen string literal 2019-06-23 07:56:43 +09:00
thread_fd_close
time
tracepoint
typeddata
vm
wait_for_single_fd
win32
test_bug-3571.rb
test_bug-5832.rb
test_notimplement.rb
test_printf.rb
test_recursion.rb
test_scan_args.rb The combination of non-Symbol keys and Symbol keys is now allowed again 2019-03-11 12:48:33 +00:00