3 ms·
a is a mapped string. You could do: c=[];n=0;a.lines{|x|c<<(n+=x.size)-1} but $"\n" wasn't special, and this allocates tons of memory. tinco's implementat
by geocar 12y ago
a is a mapped string. You could do:
c=[];n=0;a.lines{|x|c<<(n+=x.size)-1}
but $"\n" wasn't special, and this allocates tons of memory. tinco's implementation is much closer to what k is actually doing.