Skip to content

Commit ae3703c

Browse files
committed
Stop compressing integer lists
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.
1 parent 379e2bf commit ae3703c

File tree

8 files changed

+20103
-7100
lines changed

8 files changed

+20103
-7100
lines changed

lib/racc/parserfilegenerator.rb

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -320,50 +320,6 @@ def state_transition_table
320320
end
321321

322322
def integer_list(name, table)
323-
if table.size > 2000
324-
serialize_integer_list_compressed name, table
325-
else
326-
serialize_integer_list_std name, table
327-
end
328-
end
329-
330-
def serialize_integer_list_compressed(name, table)
331-
# TODO: this can be made a LOT more clean with a simple split/map
332-
sep = "\n"
333-
nsep = ",\n"
334-
buf = String.new
335-
com = ''
336-
ncom = ','
337-
co = com
338-
@f.print 'clist = ['
339-
table.each do |i|
340-
buf << co << i.to_s; co = ncom
341-
if buf.size > 66
342-
@f.print sep; sep = nsep
343-
@f.print "'", buf, "'"
344-
buf = String.new
345-
co = com
346-
end
347-
end
348-
unless buf.empty?
349-
@f.print sep
350-
@f.print "'", buf, "'"
351-
end
352-
line ' ]'
353-
354-
@f.print(<<-End)
355-
#{name} = arr = ::Array.new(#{table.size}, nil)
356-
idx = 0
357-
clist.each do |str|
358-
str.split(',', -1).each do |i|
359-
arr[idx] = i.to_i unless i.empty?
360-
idx += 1
361-
end
362-
end
363-
End
364-
end
365-
366-
def serialize_integer_list_std(name, table)
367323
sep = ''
368324
line "#{name} = ["
369325
table.each_slice(10) do |ns|

test/regress/cast

Lines changed: 870 additions & 353 deletions
Large diffs are not rendered by default.

test/regress/huia

Lines changed: 454 additions & 165 deletions
Large diffs are not rendered by default.

test/regress/nasl

Lines changed: 806 additions & 316 deletions
Large diffs are not rendered by default.

test/regress/opal

Lines changed: 5551 additions & 1875 deletions
Large diffs are not rendered by default.

test/regress/riml

Lines changed: 1338 additions & 584 deletions
Large diffs are not rendered by default.

test/regress/ruby18

Lines changed: 5397 additions & 1796 deletions
Large diffs are not rendered by default.

test/regress/ruby22

Lines changed: 5687 additions & 1967 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)