Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re^5: To Single Quote or to Double Quote: a benchmark

by eric256 (Parson)
on Feb 03, 2005 at 16:21 UTC ( #427695=note: print w/replies, xml ) Need Help??


in reply to Re^4: To Single Quote or to Double Quote: a benchmark
in thread To Single Quote or to Double Quote

If you read my post you'll see I added the "no $" after the original post. Ignoring those cases the single quote wins. You can blame the extra character if you want but i beleive that is the whole point here. If you use double quotes then you have to escape characters and it makes a noticable difference in speed. You should also have noticed that I mentioned the speed gain is minimal at very best. There is no reason at all to use these speed tests in a design choice.

for the rest because processing a backslash in a double quoted string means checking more cases than in a single quoted string. Isn't that realy the point that I was showing. Double quotes ARE slower because of the restrictions they impose, but they are only slower if it actualy contains something that needs escaped. Is that speed difference important? I would say not in normal use, but maybe for some special case.


___________
Eric Hodges
  • Comment on Re^5: To Single Quote or to Double Quote: a benchmark

Replies are listed 'Best First'.
Re^6: To Single Quote or to Double Quote: a benchmark
by Anonymous Monk on Feb 04, 2005 at 08:13 UTC
    Double quotes ARE slower because of the restrictions they impose, but they are only slower if it actualy contains something that needs escaped.
    Indeed, but let's go back to where it all started, shall we? Here's what the OP wrote:
    On occasions such as those when you don't care about the special properties of either single or double quotes, which is the best to use.
    Which to me means, the OP is talking about strings which don't have characters that are special - where the syntax of having single or double quotes doesn't matter. Obviously, if you have scalar or array sigils, or backslashes, the special properties of single or double quotes do matter - and are not the occasions we are talking about.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (3)
As of 2021-10-21 09:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My first memorable Perl project was:







    Results (83 votes). Check out past polls.

    Notices?