Re: New function: spl_object_id() or spl_object_handle()
| From: | Ferenc Kovacs | Date: | Fri, 28 Nov 2014 17:16:23 +0000 |
| Subject: | Re: New function: spl_object_id() or spl_object_handle() | ||
| References: | 1 2 3 4 5 6 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-79283@lists.php.net to get a copy of this message | ||
On Fri, Nov 28, 2014 at 5:39 PM, Patrick Schaaf <php@bof.de> wrote:
>
> Am 28.11.2014 15:46 schrieb "Ferenc Kovacs" <tyra3l@gmail.com>:
> >
> > from a quick test using spl_object_hash seems to be the slower with big
> number of elements in haystack.
>
> Your test only does the is-it-known test once. For an already-visited-set
> use case the test will run once for each visited element, and will usually
> fail, too, thus running the whole already built haystack at each point from
> front to end with in_array - overall N*(N/2) test + N*simple-array-append
> for the in_array approach, vs. N test + N*spl_object_hash-append.
>
> best regards
> Patrick
>
you are right, the actual visited set pattern is much more favorable for
the hash lookups.
--
Ferenc Kovács
@Tyr43l - http://tyrael.hu