Jump to content

Resource type for storing object properties ?


micha

Recommended Posts

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

 

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)

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

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.