std.data.json formal review

Andrei Alexandrescu via Digitalmars-d digitalmars-d at puremagic.com
Tue Aug 18 09:35:37 PDT 2015


On 8/18/15 12:31 PM, Dmitry Olshansky wrote:
> On 18-Aug-2015 16:19, Andrei Alexandrescu wrote:
>> On 8/18/15 2:55 AM, Dmitry Olshansky wrote:
>>> On 18-Aug-2015 01:33, Andrei Alexandrescu wrote:
>>>> On 8/17/15 2:47 PM, Dmitry Olshansky wrote:
>>>>>
>>>>> Actually one can combine the two:
>>>>> - use integer type tag for everything built-in
>>>>> - use pointer tag for what is not
>>>>
>>>> But a pointer tag can do everything that an integer tag does. -- Andrei
>>>
>>> albeit quite a deal slooower.
>>
>> I think there's a misunderstanding. Pointers _are_ 64-bit integers and
>> may be compared as such. You can use a pointer as an integer. -- Andrei
>>
>
> Integer in a small range is faster to switch on. Plus comparing to zero
> is faster, so if the common type has tag == 0 it's a net gain.

Agreed. These are small gains though unless tight loops are concerned.

> Strictly speaking pointer with vtbl is about as fast as switch but when
> we have to switch on 2 types the vtbl dispatch needs to be based on 2
> types instead of one. So ideally we need vtbl per pair of type to
> support e.g. fast binary operators on TaggedAlgebraic.

But I'm talking about using pointers for indirect calls IN ADDITION to 
using pointers for simple integral comparison. So the comparison is not 
appropriate. It's better to have both options instead of just one.


Andrei



More information about the Digitalmars-d mailing list