Moriyoshi Koizumi wrote:
Hi,

On Thu, Mar 25, 2010 at 8:41 AM, Stanislav Malyshev <s...@zend.com> wrote:
Hi!

Wouldn't it suffice to add a field for the hash value and a flag that
indicates its validity to zval instead of appending zend_literal
everywhere?
Enlarging zval would be costly (the engine uses tons of zvals) and may also
be more complicated to track (all zval operations now would also have to
take care to set the flag right - what if we forget in some extension to set
it right?). I think it's better not to mess with zval.

If all the constants were "intern"ed, then we should not need
zend_literal in the first place because we can store the hash values
separately in an array whose indices correspond to those of the
interned string vector.

In general you are right, but having separate hash_value for constant operands allow us to specialize executor in more efficient way. Also, the interned strings buffer may be overflown (or disabled) and in this case we will have regular strings for constants.

 Plus, I think the hash value can be stored in
the following extra bytes of the string buffer pointed by str.val.

Do you mean interned or regular strings?
For interned strings we already do near the same as you suggest.

Thanks. Dmitry.

Moriyoshi


--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to