Hacker News new | ask | show | jobs
by geocar 4256 days 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.