Summary: Constant array translated to unnecessary array literal
           Product: D
           Version: 2.041
          Platform: x86
        OS/Version: All
            Status: NEW
          Keywords: performance
          Severity: normal
          Priority: P2
         Component: DMD

--- Comment #0 from Shin Fujishiro <> 2010-06-08 17:57:52 PDT 
Using constant (const or immutable) dynamic array causes unnecessary
array literal creation if the constant array has an initializer.

This behavior degrades performance, and also causes the bug 4297.

Test code and the disassembled output:
immutable int[] TABLE = [ 1, 2, 3 ];
void foo()
    const(int)[] tab = TABLE;
        push    EBP
        mov    EBP,ESP
        push    EBX
        push    3
        push    2
        push    1
        push    3
        mov    EAX,offset FLAT:_d12typeinfo_axi6__in...@sym32
        push    EAX
        call      _d_arrayliter...@pc32
        mov    ECX,EAX
        mov    EBX,3
        add    ESP,014h
        pop    EBX
        pop    EBP

Configure issuemail:
------- You are receiving this mail because: -------

Reply via email to