Resource type for storing object properties ?
Posted 21 April 2004 - 08:35 PM
I wonder if a resource could be an option for storing object properties due to performance issues ?
In most of the class methods I have to access more than on member variable, so if I need access to e.g. 4 vars, zend_hash_find has to be called 4 times. For a resource which holds a structure with all member vars one call to ZEND_FETCH_RESOURCE would do it.
Well, does this make sense ?
Posted 21 April 2004 - 09:14 PM
Lord Daeken M. BlackBlade
Posted 21 April 2004 - 09:47 PM
wow, thanks for your fast response.
This _could_ be done... however, this would mean you couldn't let PHP access them directly, like an object.
Yeah, this is ok since all vars are private (php4) and have appropriate get and set methods.
However, theoretically it should be possible to have both by storing the same pointer into the objects property hashtable and into the resources structure, shouldn't it ?
If it's just for internal use, go for it, otherwise I'd stick with normal objects.
Ok, great. They are all used internally and as a nice side effect I get *real* private vars and can be sure that the user doesn't change them.
Btw, do you know if fetching a resource is as fast as finding a hash entry...or even faster ?
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users