[wp-hackers] Micro optimization - is_a() vs instanceof

Dobri dyordan1 at ramapo.edu
Fri Jan 4 19:57:49 UTC 2013

I haven't tested this myself, but according to the tests in http://stackoverflow.com/a/3017722, the two statements are equivalent. I'd only assume that to be so since it's the logical thing to do and PHP tends to be logical. In fact, if you had two objects $a and $b with the same class or parent class $a instanceof $b would still return true, which is rather peculiar. Regardless, the patch should still work. Cheers!

On Fri, 4 Jan 2013, at 2:49 PM, Andrew Nacin wrote:

> On Fri, Jan 4, 2013 at 2:47 PM, Justas Butkus <jbutkus at time.ly> wrote:
>> What a pity would be to curtail such a lunch, or at least a sensual impact
>> of it, by doing a code replacement over it.
>> There was no offence intended, and please find my patch attached, that
>> would dismantle the cause of this issue, if applied, to alleviate my good
>> intentions.
>> The rationale behind my comment was just as good - to break the discussion
>> about time consumption, while the change itself takes less time than
>> thinking about it.
> You should take a lunch to test your patch :-)
> $a instanceof Some_Object
> not
> $a instanceof 'Some_Object'
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers


More information about the wp-hackers mailing list