-
-
Save bbrowning/90c2296e048fb806b4a1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# 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