summaryrefslogtreecommitdiffhomepage
path: root/src/string.c
diff options
context:
space:
mode:
authordearblue <[email protected]>2021-06-28 23:04:43 +0900
committerdearblue <[email protected]>2021-06-28 23:04:43 +0900
commit59201b59046b9e73c309508350cd3c0fafd20e4d (patch)
tree8324908ff5b72bc5da89e97a7dccf8e0a6acc220 /src/string.c
parentd63c0df6bcd5851522c4b982dba4e0a93f44a2d7 (diff)
downloadmruby-59201b59046b9e73c309508350cd3c0fafd20e4d.tar.gz
mruby-59201b59046b9e73c309508350cd3c0fafd20e4d.zip
Drop unnecessary upper procs linked from class/module/def syntax
It does not need to hold an anonymous proc for constant search. Also, this change can be expected to cause an anonymous proc to be GC'd. This is useful for metaprogramming that makes heavy use of the `class`/`module`/`def` syntax in the `class_eval`/`eval` method. Example: - code ```ruby p ObjectSpace.count_objects String.class_eval do def a end end p ObjectSpace.count_objects String.class_eval do eval <<~CODE def b end CODE end p ObjectSpace.count_objects ``` - result of building mruby-head (d63c0df6b) with `build_config/default.rb` ``` {:TOTAL=>1024, :FREE=>262, :T_PROC=>495, :T_ENV=>61, ...} {:TOTAL=>1024, :FREE=>259, :T_PROC=>497, :T_ENV=>62, ...} {:TOTAL=>1024, :FREE=>255, :T_PROC=>500, :T_ENV=>63, ...} ``` - result of building mruby with this patch and `build_config/default.rb` ``` {:TOTAL=>1024, :FREE=>264, :T_PROC=>494, :T_ENV=>60, ...} {:TOTAL=>1024, :FREE=>262, :T_PROC=>495, :T_ENV=>61, ...} {:TOTAL=>1024, :FREE=>261, :T_PROC=>496, :T_ENV=>61, ...} ```
Diffstat (limited to 'src/string.c')
0 files changed, 0 insertions, 0 deletions