From: Gregory Brown Date: 2008-07-31T07:18:46+09:00 Subject: Re: Suggestions for improving a trivial tag parser On Wed, Jul 30, 2008 at 6:12 PM, Robert Dober wrote: > On Wed, Jul 30, 2008 at 10:43 PM, Gregory Brown > wrote: > >> It does a double pass through the segments rather than a single pass, > Yes but these two passes are quite fast, see below. >> However, I think it'll be okay for my purposes (PDF inline styling), >> unless I missed some other concern Rolando had. > Well trying to be useful I checked for some larger texts, I omitted > the conditional #first at the end of the parsing method for clarity. > > Turns out that split is still much better than scanning for a string > of a size over one megabyte, but it is not > really fast either: > 539/39 > cat split.rb && ruby split.rb Interesting that it's faster to do a double pass with split than a single pass with StringScanner. I didn't implement it that way for efficiency, just out of total forgetfulness on how to get split() to work the way I want :) -greg