Re: Re: optimilize web page loading

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



At 10:59 AM -0400 3/28/08, Robert Cummings wrote:
Nope, when processing a single quoted string there should be 4 available
parse branches:

    EOF
    '    (end of string)
    \
        EOF
        \
        '
        anything else
    anything else

Whereas with a double quoted string you have something along the lines
of:

    EOF
    "    (end of string)
    $    (begin variable)
    {    (possible begin interpolation)
        $    (begin interpolation)
    \
        EOF
        \
        '
        "
        t
        n
        r
        x
        v
        f
        <digit>
        anything else
    anything else

So presuming no variable is embeded and assuming no escaped
characters... double quotes still need to check for the beginning of
variable interpolation which has 2 different start possibilities. With
respect to creating the byte code single quotes have 4 branches, double
quotes have 6 branches in the simplest of cases with no escape and no
interpolation. So one would expect compile time for double quotes to be
approximately 33% slower than for single quotes. Once compiled though,
the point is moot especially since most sites use a bytecode cache like
eAccelerator or APC. Even without a cache htough, the time difference is
teeeeeeeency, and this is just for informational purposes :) There are
usually bigger eggs to fry when optimizing. One last thing though...
even if this were escaped and even if there were fifty variables
embedded, a good bytecode optimizer (not quite the same as a bytecode
cacher) would optimize the bytecode for caching so that the string is
broken up according to what needs to be interpolated and what does not.

As always, thanks for your most excellent explanation. I figured that something along those lines was happening. I didn't consider the escape concerns.

Cheers,

tedd

--
-------
http://sperling.com  http://ancientstones.com  http://earthstones.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux