micha Posted April 21, 2004 Share Posted April 21, 2004 Hi, 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 ? micha Quote Link to comment https://forums.phpfreaks.com/topic/1805-resource-type-for-storing-object-properties/ Share on other sites More sharing options...
daeken Posted April 21, 2004 Share Posted April 21, 2004 This _could_ be done... however, this would mean you couldn't let PHP access them directly, like an object. If it's just for internal use, go for it, otherwise I'd stick with normal objects. Happy Hacking, Lord Daeken M. BlackBlade (Cody Brocious) Quote Link to comment https://forums.phpfreaks.com/topic/1805-resource-type-for-storing-object-properties/#findComment-5920 Share on other sites More sharing options...
micha Posted April 21, 2004 Author Share Posted April 21, 2004 Hi daeken, 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 ? Thx, micha Quote Link to comment https://forums.phpfreaks.com/topic/1805-resource-type-for-storing-object-properties/#findComment-5921 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.