diff options
author | Aaron Patterson <tenderlove@ruby-lang.org> | 2024-04-17 16:30:41 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2024-04-18 09:06:33 -0700 |
commit | 147ca9585ede559fd68e162cbbbaba84f009c9a1 (patch) | |
tree | fea2464e46cedbdcd6b6882f908948fd7313647d /lib/rake/contrib | |
parent | 8e08556fa7f2b6e9c43b040f2aea06dccead5d13 (diff) |
When we're searching for CCs, compare the argc and flags for CI rather
than comparing pointers. This means we don't need to store a reference
to the CI, and it also naturally "de-duplicates" CC objects.
We can observe the effect with the following code:
```ruby
require "objspace"
hash = {}
p ObjectSpace.memsize_of(Hash)
eval ("a".."zzz").map { |key|
"hash.merge(:#{key} => 1)"
}.join("; ")
p ObjectSpace.memsize_of(Hash)
```
On master:
```
$ ruby -v test.rb
ruby 3.4.0dev (2024-04-15T16:21:41Z master d019b3baec) [arm64-darwin23]
test.rb:3: warning: assigned but unused variable - hash
3424
527736
```
On this branch:
```
$ make runruby
compiling vm.c
linking miniruby
builtin_binary.inc updated
compiling builtin.c
linking static-library libruby.3.4-static.a
ln -sf ../../rbconfig.rb .ext/arm64-darwin23/rbconfig.rb
linking ruby
ld: warning: ignoring duplicate libraries: '-ldl', '-lobjc', '-lpthread'
RUBY_ON_BUG='gdb -x ./.gdbinit -p' ./miniruby -I./lib -I. -I.ext/common ./tool/runruby.rb --extout=.ext -- --disable-gems ./test.rb
2240
2368
```
Co-authored-by: John Hawthorn <jhawthorn@github.com>
Diffstat (limited to 'lib/rake/contrib')
0 files changed, 0 insertions, 0 deletions