std.data.json formal review

Andrei Alexandrescu via Digitalmars-d digitalmars-d at puremagic.com
Tue Aug 18 07:58:17 PDT 2015


On 8/18/15 7:02 AM, Johannes Pfau wrote:
> Am Tue, 18 Aug 2015 09:10:25 +0000
> schrieb "Marc Sch├╝tz" <schuetzm at gmx.net>:
>
>> On Monday, 17 August 2015 at 22:34:36 UTC, Andrei Alexandrescu
>> wrote:
>>> On 8/17/15 2:51 PM, deadalnix wrote:
>>>>   From the compiler perspective, the tag is much nicer.
>>>> Compiler can use
>>>> jump table for instance.
>>>
>>> The pointer is a more direct conduit to a jump table.
>>
>> Not really, because it most likely doesn't point to where you
>> need it, but to a `TypeInfo` struct instead, which doesn't help
>> you in a `switch` statement. Besides, you probably shouldn't
>> compare pointers vs integers, but pointers vs enums.
>
> Here's an example with an enum tag, showing what compilers can do:
> http://goo.gl/NUZwNo
>
> ARM ASM is easier to read for me. Feel free to switch to X86.
>
> The jump table requires only one instruction (the cmp #4 shouldn't be
> necessary for a final switch, probably a GDC/GCC enhancement). All
> instructions/data should be in the instruction cache. There's no
> register save / function call overhead.
>
>
> If you use a pointer:
> http://goo.gl/9kb0vQ

That's a language issue - switch does not work with any pointers. I just 
submitted https://issues.dlang.org/show_bug.cgi?id=14931. -- Andrei



More information about the Digitalmars-d mailing list