Re: cvs: php-src /ext/spl spl_observer.c /ext/spl/internal splobjectstorage.inc /ext/spl/tests observer_002.phpt
| From: | Marcus Boerger | Date: | Wed, 10 Aug 2005 23:46:17 +0000 |
| Subject: | Re: cvs: php-src /ext/spl spl_observer.c /ext/spl/internal splobjectstorage.inc /ext/spl/tests observer_002.phpt | ||
| References: | 1 2 3 4 5 6 | Groups: | php.cvs |
| Request: | Send a blank email to php-cvs+get-33289@lists.php.net to get a copy of this message | ||
Hello Andrei,
it would only help if the schema used is always the same so that it is
trustably unique. The following two lines achieve that:
char *key;
spprintf(&key, 0, "%s::%d", Z_OBJCE_P(obj)->name, obj->value.obj.handle);
Yep would help in a few edge cases and allow O(1) implementation of
ObjectStorage.
regards
marcus
Thursday, August 11, 2005, 1:30:14 AM, you wrote:
> What we really need is a get_hash_t handler on the object, so that each
> object knows how to hash itself. This can also come in handy when using
> objects as array keys.
> -Andrei
> On Aug 10, 2005, at 3:39 PM, Marcus Boerger wrote:
>> Hello Andrey,
>>
>> wrong assumption. That is only the handle but only the handle+handler
>> combination is unique.
>>
>> marcus
>>
>> Thursday, August 11, 2005, 12:32:07 AM, you wrote:
>>
>>> Marcus Boerger wrote:
>>>> Hello Andrey,
>>>>
>>>> thanks! I wanted to do it earlier but had no idea how to sole the
>>>> problem.
>>>> I actually right from the beginning wanted to do all three in there.
>>>> Anyway
>>>> you might also want to see t he last slides of my last presentation
>>>> (the one
>>>> from OSCON) which you can find here:
>>>> http://talks.somabo.de/
>>>>
>>>> best regards
>>>> marcus
>>>>
>>>> Thursday, August 11, 2005, 12:04:37 AM, you wrote:
>>>>
>>>>
>>>>> Wonderful idea Helly!
>>>>
>>>>
>>>>> Andrey
>>>>
>>>>
>>
>>> However, I think you are wrong that it cannot be implemented in user
>>> land with O(1)
>>> complexity. The following one-liner should give you a hint why I
>>> think it is possible.
>>
>>> andrey@lmy004:~/test> php -r 'class a{} function get_hash_key($obj){
>>> ob_start();
>>> var_dump($obj); $v=ob_get_contents();
>>> ob_end_clean();var_dump(substr($v, 7, strpos($v, "
>>> ", 11) - 7));} get_hash_key(new a);'
>>> string(4) "a)#1"
>>
>>> The string is unique per object. ) and # are noise but they are not a
>>> problem.
>>
>>> Best wishes,
>>> Andrey
>>
>>
>>
>> Best regards,
>> Marcus
>>
>> --
>> PHP CVS Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
Best regards,
Marcus