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:
if ($teststring ne '') {
...
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 "".
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.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.