Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re^3: In search of an efficient query abstractor

by Corion (Patriarch)
on Dec 07, 2008 at 20:50 UTC ( [id://728786]=note: print w/replies, xml ) Need Help??


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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://728786]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (8)
As of 2024-04-23 07:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found