On an otherwise unloaded P4 1.g GHz
For certain very specific meanings of the word "unloaded", I'm sure. "foo" is optimized to 'foo' at compile time, so neither of them can possibly be faster. As you can see, the generated bytecode is equivalent:
2;0 juerd@ouranos:~$ perl -MO=Concise -e'$foo = "foo"'
6 <@> leave[t1] vKP/REFC ->(end)
1 <0> enter ->2
2 <;> nextstate(main 1 -e:1) v ->3
5 <2> sassign vKS/2 ->6
3 <$> const(PV "foo") s ->4
- <1> ex-rv2sv sKRM*/1 ->5
4 <$> gvsv(*foo) s ->5
-e syntax OK
2;0 juerd@ouranos:~$ perl -MO=Concise -e'$foo = '\''bar'\'
6 <@> leave[t1] vKP/REFC ->(end)
1 <0> enter ->2
2 <;> nextstate(main 1 -e:1) v ->3
5 <2> sassign vKS/2 ->6
3 <$> const(PV "bar") s ->4
- <1> ex-rv2sv sKRM*/1 ->5
4 <$> gvsv(*foo) s ->5
-e syntax OK
Even "Hello, $name!" is optimized to 'Hello, ' . $name . '!'.
Note: I _do_ think people should use single quotes when not interpolating. It saves you a lot of hits on the backslash key, and avoids getting bitten by: "$You're kidding me" (eq. "$You::re kidding me"), "my@emailaddress.com" (intended: "my\@emailaddress.com").
- Yes, I reinvent wheels.
- Spam: Visit eurotraQ.
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|