зеркало из https://github.com/github/ruby.git
d3574c117a
This commit moves IO#readline to Ruby. In order to call C functions, keyword arguments must be converted to hashes. Prior to this commit, code like `io.readline(chomp: true)` would allocate a hash. This commits moves the keyword "denaturing" to Ruby, allowing us to send positional arguments to the C API and avoiding the hash allocation. Here is an allocation benchmark for the method: ``` x = GC.stat(:total_allocated_objects) File.open("/usr/share/dict/words") do |f| f.readline(chomp: true) until f.eof? end p ALLOCATIONS: GC.stat(:total_allocated_objects) - x ``` Before this commit, the output was this: ``` $ make run ./miniruby -I./lib -I. -I.ext/common -r./arm64-darwin22-fake ./test.rb {:ALLOCATIONS=>707939} ``` Now it is this: ``` $ make run ./miniruby -I./lib -I. -I.ext/common -r./arm64-darwin22-fake ./test.rb {:ALLOCATIONS=>471962} ``` [Bug #19890] [ruby-core:114803] |
||
---|---|---|
.. | ||
array.h | ||
basic_operators.h | ||
bignum.h | ||
bits.h | ||
class.h | ||
cmdlineopt.h | ||
compar.h | ||
compile.h | ||
compilers.h | ||
complex.h | ||
cont.h | ||
dir.h | ||
enc.h | ||
encoding.h | ||
enum.h | ||
enumerator.h | ||
error.h | ||
eval.h | ||
file.h | ||
fixnum.h | ||
gc.h | ||
hash.h | ||
imemo.h | ||
inits.h | ||
io.h | ||
load.h | ||
loadpath.h | ||
math.h | ||
missing.h | ||
numeric.h | ||
object.h | ||
parse.h | ||
proc.h | ||
process.h | ||
ractor.h | ||
random.h | ||
range.h | ||
rational.h | ||
re.h | ||
ruby_parser.h | ||
sanitizers.h | ||
serial.h | ||
signal.h | ||
static_assert.h | ||
string.h | ||
struct.h | ||
symbol.h | ||
thread.h | ||
time.h | ||
transcode.h | ||
util.h | ||
variable.h | ||
vm.h | ||
warnings.h |