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 Add test cases of rb_arithmetic_sequence_extract 2018-12-12 21:17:04 +00:00
array
bignum
bug_reporter test_bug_reporter.rb: make it work with --jit 2018-04-28 09:02:56 +00:00
class
debug Adjust indent 2019-05-10 22:00:22 +09:00
exception
file
float
funcall
gvl introduce rb_nogvl C-API to mark ubf as async-signal-safe 2019-01-04 13:14:11 +00:00
hash
integer numeric.c: fix infinite loop 2019-03-11 01:37:16 +00:00
iseq_load test_iseq_load.rb: increase timeout for stressful roundtrip 2018-12-29 01:53:10 +00:00
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 revert revert of r65285 2018-10-21 23:20:32 +00:00
time
tracepoint
typeddata
vm
wait_for_single_fd test_wait_for_single_fd.rb: remove with_pipe helper 2018-05-14 23:51:39 +00:00
win32
test_bug-3571.rb
test_bug-5832.rb
test_notimplement.rb Add more assertions for NotImplementedError of instance method 2018-08-21 14:57:56 +00:00
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