in reply to Re^2: In search of an efficient query abstractor
in thread In search of an efficient query abstractor

At least for the last case, Perl has an optimized version:

$query =~ tr[ ][]s;

and it should be faster or at least as fast as the s/// version. Another version to try would be s/\s+/ /g - there is no need to use the counting variant of {2,}, and skipping might be slower than just writing the output "replacement".

Replies are listed 'Best First'.
Re^4: In search of an efficient query abstractor
by xaprb (Scribe) on Dec 08, 2008 at 01:19 UTC

    $query =~ tr[ \n\t\r\f][ ]s; turns out to be a lot faster than any s/// variant. That change moves this line from #4 badness to #28 badness. Still having trouble with the floats, though.