Skip to content

Commit

Permalink
Stop compressing integer lists
Browse files Browse the repository at this point in the history
It is unclear why this was implemented, I assume
it was for performance back in 2006.

However today, this compression defeats bytecode caching
entirely and end up being counter productive.
  • Loading branch information
byroot committed May 31, 2021
1 parent 379e2bf commit ae3703c
Show file tree
Hide file tree
Showing 8 changed files with 20,103 additions and 7,100 deletions.
44 changes: 0 additions & 44 deletions lib/racc/parserfilegenerator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -320,50 +320,6 @@ def state_transition_table
end

def integer_list(name, table)
if table.size > 2000
serialize_integer_list_compressed name, table
else
serialize_integer_list_std name, table
end
end

def serialize_integer_list_compressed(name, table)
# TODO: this can be made a LOT more clean with a simple split/map
sep = "\n"
nsep = ",\n"
buf = String.new
com = ''
ncom = ','
co = com
@f.print 'clist = ['
table.each do |i|
buf << co << i.to_s; co = ncom
if buf.size > 66
@f.print sep; sep = nsep
@f.print "'", buf, "'"
buf = String.new
co = com
end
end
unless buf.empty?
@f.print sep
@f.print "'", buf, "'"
end
line ' ]'

@f.print(<<-End)
#{name} = arr = ::Array.new(#{table.size}, nil)
idx = 0
clist.each do |str|
str.split(',', -1).each do |i|
arr[idx] = i.to_i unless i.empty?
idx += 1
end
end
End
end

def serialize_integer_list_std(name, table)
sep = ''
line "#{name} = ["
table.each_slice(10) do |ns|
Expand Down
1,223 changes: 870 additions & 353 deletions test/regress/cast

Large diffs are not rendered by default.

619 changes: 454 additions & 165 deletions test/regress/huia

Large diffs are not rendered by default.

1,122 changes: 806 additions & 316 deletions test/regress/nasl

Large diffs are not rendered by default.

7,426 changes: 5,551 additions & 1,875 deletions test/regress/opal

Large diffs are not rendered by default.

1,922 changes: 1,338 additions & 584 deletions test/regress/riml

Large diffs are not rendered by default.

7,193 changes: 5,397 additions & 1,796 deletions test/regress/ruby18

Large diffs are not rendered by default.

7,654 changes: 5,687 additions & 1,967 deletions test/regress/ruby22

Large diffs are not rendered by default.

0 comments on commit ae3703c

Please sign in to comment.