RE: [PHP-DEV] Performance of buffer based functionality (JSON, AES, serialize())
| From: | Jonathan Bond-Caron | Date: | Thu, 02 Dec 2010 17:11:32 +0000 |
| Subject: | RE: [PHP-DEV] Performance of buffer based functionality (JSON, AES, serialize()) | ||
| References: | 1 2 3 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-50830@lists.php.net to get a copy of this message | ||
On Tue Nov 30 03:26 AM, Julien Pauli wrote:
> I guess serialize mechanism cant use any char that can be part of a
> PHP variable. And "_" can. As property names respect binary
> compatibility, the only char that can be used to mark private
> properties is actually the NULL byte. Ping me if I'm wrong.
>
Right, what I was proposing didn't make sense. After digging through the source, say we have:
class Foo {
public $a = 1;
protected $b = 2;
private $c = 3;
}
Currently this is:
O:3:"Foo":3:{s:1:"a";i:1;s:4:"�*�b";i:2;s:6:"�Foo�c";i:3;}
An alternative could be:
O:3:"Foo":3:{s:1:"a";i:1;*;s:4:"b";i:2;_;s:6:"c";i:3;}
Where "*;" is a marker for protected, "_;" is a marker for private
It would involve some trickery in ext/standard/var_unserializer.re :
"*;" {
/* prepend �*� to the next key so that we have zend_symtable_find("�*�b") */
}
"_;" {
/* prepend �Foo� to the next key so that we have
zend_symtable_find("�Foo�c") */
}
Just a thought if someone wants to refactor it / look into performance, I believe that approach
would support both:
O:3:"Foo":3:{s:1:"a";i:1;*;s:4:"b";i:2;_;s:6:"c";i:3;}
O:3:"Foo":3:{s:1:"a";i:1;s:4:"�*�b";i:2;s:6:"�Foo�c";i:3;}