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

 

Link to comment
Share on other sites

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)

Link to comment
Share on other sites

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

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.