Backport #8149

[patch] iseq: remove duplicate strings for file paths

Added by Aman Gupta about 1 year ago. Updated 9 months ago.

[ruby-core:53639]
Status:Closed
Priority:Normal
Assignee:Tomoyuki Chikanaga

Description

with:
./ruby -Ilib -e' GC.start; p ObjectSpace.eachobject(String).toa.select{ |s| s =~ /rubygems\/defaults/ }.inject(Hash.new 0){|h,s| h[s]+=1; h} '

before:
{"/Users/test/code/ruby-trunk/lib/rubygems/defaults.rb"=>3}

after:
{"/Users/test/code/ruby-trunk/lib/rubygems/defaults.rb"=>1}

diff --git a/iseq.c b/iseq.c
index 288d3bf..72c92bd 100644
--- a/iseq.c
+++ b/iseq.c
@@ -188,7 +188,10 @@ iseqlocationsetup(rbiseqt *iseq, VALUE path, VALUE absolutepath, VALUE name
{
rb
iseqlocationt *loc = &iseq->location;
loc->path = path;
- loc->absolutepath = absolutepath;
+ if (RTEST(absolutepath) && rbstrcmp(path, absolutepath) == 0)
+ loc->absolutepath = path;
+ else
+ loc->absolute
path = absolutepath;
loc->label = loc->base
label = name;
loc->firstlineno = firstlineno;
return loc;

Associated revisions

Revision 42089
Added by Tomoyuki Chikanaga 9 months ago

merge revision(s) 40334: [Backport #8149]

* iseq.c (iseq_location_setup): re-use existing string when iseq has
  the same path and absolute_path. [Bug #8149]

History

#1 Updated by Aman Gupta 12 months ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100

This issue was solved with changeset r40334.
Aman, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


iseq.c: remove duplicated strings for file paths

  • iseq.c (iseqlocationsetup): re-use existing string when iseq has the same path and absolute_path. [Bug #8149]

#2 Updated by Aman Gupta 11 months ago

  • Tracker changed from Bug to Backport
  • Project changed from ruby-trunk to Backport200
  • Status changed from Closed to Assigned
  • Assignee changed from Koichi Sasada to Tomoyuki Chikanaga

#3 Updated by Tomoyuki Chikanaga 9 months ago

  • Status changed from Assigned to Closed

This issue was solved with changeset r42089.
Aman, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


merge revision(s) 40334: [Backport #8149]

* iseq.c (iseq_location_setup): re-use existing string when iseq has
  the same path and absolute_path. [Bug #8149]

Also available in: Atom PDF