Just a small meditation that wondered past my frontal lobes recently:
In my own code, when I need to see if a string is empty, I go for something along the lines of:
But... recently my brain has been probing the possibility that my assumption is false.
Does perl have a precompiled shortcut for dealing with ""?
Does perl have some magical process where "" is evaluated at the same speed (or faster?) than its '' brethren?
I know in my heart that the difference between the two alternatives is probably no more than a few cycles and I'll probably squander what savings are made through that rather nasty regex further on in the code... but it's been bugging the ol' hamsters wheel for a while now.
Thank you for your microwave popcorn time.
In my own code, when I need to see if a string is empty, I go for something along the lines of:
As opposed to the more common variation of:if ($teststring ne '') { ...
My reasoning, up this point, has been that it's less work for the perl engine to compare against a(n almost) literal of '' then have to go through the parse cycle and then compare for a "".if ($teststring ne "") { ...
But... recently my brain has been probing the possibility that my assumption is false.
Does perl have a precompiled shortcut for dealing with ""?
Does perl have some magical process where "" is evaluated at the same speed (or faster?) than its '' brethren?
I know in my heart that the difference between the two alternatives is probably no more than a few cycles and I'll probably squander what savings are made through that rather nasty regex further on in the code... but it's been bugging the ol' hamsters wheel for a while now.
Thank you for your microwave popcorn time.
|
---|
Replies are listed 'Best First'. | |
---|---|
(tye)Re: A better non-existant string...
by tye (Sage) on Jan 23, 2001 at 04:24 UTC | |
by spaz (Pilgrim) on Jan 23, 2001 at 06:42 UTC | |
by tye (Sage) on Jan 23, 2001 at 11:44 UTC | |
Re: A better non-existant string...
by extremely (Priest) on Jan 23, 2001 at 06:43 UTC | |
by lzcd (Pilgrim) on Jan 23, 2001 at 06:50 UTC | |
Re: A better non-existant string...
by Adam (Vicar) on Jan 23, 2001 at 03:36 UTC | |
Re: A better non-existant string...
by chromatic (Archbishop) on Jan 24, 2001 at 05:09 UTC |
Back to
Meditations