Hi,

On Mon, May 13, 2013 at 1:24 PM, Nikita Popov <nikita....@gmail.com> wrote:

> On Mon, May 13, 2013 at 7:49 AM, Dmitry Stogov <dmi...@zend.com> wrote:
>
>> Hi Nikita,
>>
>> The patch looks quite good.
>> However, it must slow down each comparison operator (even if it compares
>> two integers).
>>
> In most cases it shouldn't, as the comparisons usually go through the
> fast_is_*_functions, which have special handling for integers and doubles.
> is_equal_function itself for example is only used in the implementation of
> ZEND_CASE (why? shouldn't we use the fast_ one here too?) and stuff like
> array_search.
>

Ahh, you are right :)


>
> I would suggest overloading of CMP operator instead of separate <, <=, ==,
>> !=, >, >=.
>>
>

> But yeah, that sounds like a better solution. The advantages I see:
> a) It will automatically work with sorting functions (and other stuff
> using compare_function). This is a pretty big plus.
> b) You don't have to implement the same (or similar) code for four (or
> six) operators.
> c) It (at least partially) also solves the concerns raised by Sara.
>

I'm glad, you are agree :)


> Would need an additional object handler though (as compare_objects works
> only on objects, so it's currently not possible to support something like
> $gmp == 0).
>
>
Or may be we may introduce additional opcode (or even pseudo-opcode)
ZEND_CMP to do it in the same way.
Also it may be better to use a table of callbacks for each overloaded
operand instead of single one that need to do switch anyway.

Thanks. Dmitry.


> Nikita
>

Reply via email to