Skip to content

Instantly share code, notes, and snippets.

@bbrowning
Last active August 29, 2015 14:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bbrowning/90c2296e048fb806b4a1 to your computer and use it in GitHub Desktop.
Save bbrowning/90c2296e048fb806b4a1 to your computer and use it in GitHub Desktop.
#
# On my machine, JRuby 9k builds OOM with a 512MB heap but JRuby
# 1.7.20 can run it without OOM in only 16MB of heap.
#
po_input = 5000.times.map do |i|
%Q{msgid"Translation #{i}"}
end.join("\n")
# Copied and simplified from fast_gettext/vendor/poparser.rb to make
# this as self-contained as possible
def parse(str)
str.strip!
@q = []
until str.empty? do
if str =~ /\A\s+/
str = str[($&.length)..-1]
elsif str =~ /\Amsgid/
@q.push [:MSGID, $&]
str = str[($&.length)..-1]
elsif str =~ /\A\".*\"/
@q.push [:STRING, $&[1..-2]]
str = str[($&.length)..-1]
end
end
end
parse(po_input)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment