Yeah, dynamic properties get used by default every time you json_decode something, to take a random example.
String folding could be used, but that would require a hashtable lookup and would probably be slower than allocation (at least until you started to swap). Worth testing maybe. Or... when you instantiate an object, it still looks like a hash, but declared property names are initialized to point at shared strings. Dynamic property names aren't. When the object is reclaimed, the declared properties are removed first to prevent double deallocations, and then the dynamic properties are destroyed. I'm suggesting a lot of work here I'm sure, but this latter idea seems like it might yield a large memory usage improvement. On Mon, May 21, 2012 at 2:55 PM, Stas Malyshev <smalys...@sugarcrm.com> wrote: > Hi! > >> How come it's necessary to store the property-names of every property >> in every object? For properties that have been defined in classes, why >> can't they be stored in a more efficient manner? (using lookup tables) > > No because you can add and remove properties freely at runtime. > >> I know the nature of PHP is dynamic, and I know that dynamic >> properties would have to be stored in a key/value form internally... >> but if you look at modern PHP software, dynamic properties is actually >> something very few people use. > > This is not true. > -- > Stanislav Malyshev, Software Architect > SugarCRM: http://www.sugarcrm.com/ > (408)454-6900 ext. 227 > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > -- Tom Boutell P'unk Avenue 215 755 1330 punkave.com window.punkave.com -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php