Download Reference Manual
The Developer's Library for D
About Wiki Forums Source Search Contact

Changeset 3697

Show
Ignore:
Timestamp:
07/02/08 14:51:58 (4 months ago)
Author:
sean
Message:

Rolled back previous changes. I'd have done this a week ago, but dsource was down and then I forgot to commit. This closes #1169

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/lib/compiler/dmd/adi.d

    r3654 r3697  
    378378extern (C) int _adEq(Array a1, Array a2, TypeInfo ti) 
    379379{ 
     380    /+ 
     381     + TODO: Re-enable once the correct TypeInfo is passed: 
     382     +       http://d.puremagic.com/issues/show_bug.cgi?id=2161 
     383     + 
    380384    debug(adi) printf("_adEq(a1.length = %d, a2.length = %d)\n", a1.length, a2.length); 
    381385 
     
    389393        return ti.equals(&a1, &a2); 
    390394    return memcmp(a1.ptr, a2.ptr, a1.length) == 0; 
     395    +/ 
     396    debug(adi) printf("_adEq(a1.length = %d, a2.length = %d)\n", a1.length, a2.length); 
     397    if (a1.length != a2.length) 
     398        return 0; // not equal 
     399    auto sz = ti.tsize(); 
     400    auto p1 = a1.ptr; 
     401    auto p2 = a2.ptr; 
     402 
     403    if (sz == 1) 
     404        // We should really have a ti.isPOD() check for this 
     405        return (memcmp(p1, p2, a1.length) == 0); 
     406 
     407    for (size_t i = 0; i < a1.length; i++) 
     408    { 
     409        if (!ti.equals(p1 + i * sz, p2 + i * sz)) 
     410            return 0; // not equal 
     411    } 
     412    return 1; // equal 
    391413} 
    392414 
     
    410432extern (C) int _adCmp(Array a1, Array a2, TypeInfo ti) 
    411433{ 
     434    /+ 
     435     + TODO: Re-enable once the correct TypeInfo is passed: 
     436     +       http://d.puremagic.com/issues/show_bug.cgi?id=2161 
     437     + 
    412438    debug(adi) printf("adCmp()\n"); 
    413439 
     
    429455        return 0; 
    430456    return a1.length > a2.length ? 1 : -1; 
     457    +/ 
     458    debug(adi) printf("adCmp()\n"); 
     459    auto len = a1.length; 
     460    if (a2.length < len) 
     461        len = a2.length; 
     462    auto sz = ti.tsize(); 
     463    void *p1 = a1.ptr; 
     464    void *p2 = a2.ptr; 
     465 
     466    if (sz == 1) 
     467    {   // We should really have a ti.isPOD() check for this 
     468        auto c = memcmp(p1, p2, len); 
     469        if (c) 
     470            return c; 
     471    } 
     472    else 
     473    { 
     474        for (size_t i = 0; i < len; i++) 
     475        { 
     476            auto c = ti.compare(p1 + i * sz, p2 + i * sz); 
     477            if (c) 
     478                return c; 
     479        } 
     480    } 
     481    if (a1.length == a2.length) 
     482        return 0; 
     483    return (a1.length > a2.length) ? 1 : -1; 
    431484} 
    432485 
  • trunk/lib/compiler/gdc/adi.d

    r3654 r3697  
    532532extern (C) int _adEq(Array a1, Array a2, TypeInfo ti) 
    533533{ 
     534    /+ 
     535     + TODO: Re-enable once the correct TypeInfo is passed: 
     536     +       http://d.puremagic.com/issues/show_bug.cgi?id=2161 
     537     + 
    534538    debug(adi) printf("_adEq(a1.length = %d, a2.length = %d)\n", a1.length, a2.length); 
    535539 
     
    543547        return ti.equals(&a1, &a2); 
    544548    return memcmp(a1.ptr, a2.ptr, a1.length) == 0; 
     549    +/ 
     550    debug(adi) printf("_adEq(a1.length = %d, a2.length = %d)\n", a1.length, a2.length); 
     551    if (a1.length != a2.length) 
     552        return 0; // not equal 
     553    auto sz = ti.tsize(); 
     554    auto p1 = a1.ptr; 
     555    auto p2 = a2.ptr; 
     556 
     557    if (sz == 1) 
     558        // We should really have a ti.isPOD() check for this 
     559        return (memcmp(p1, p2, a1.length) == 0); 
     560 
     561    for (size_t i = 0; i < a1.length; i++) 
     562    { 
     563        if (!ti.equals(p1 + i * sz, p2 + i * sz)) 
     564            return 0; // not equal 
     565    } 
     566    return 1; // equal 
    545567} 
    546568 
     
    564586extern (C) int _adCmp(Array a1, Array a2, TypeInfo ti) 
    565587{ 
     588    /+ 
     589     + TODO: Re-enable once the correct TypeInfo is passed: 
     590     +       http://d.puremagic.com/issues/show_bug.cgi?id=2161 
     591     + 
    566592    debug(adi) printf("adCmp()\n"); 
    567593 
     
    583609        return 0; 
    584610    return a1.length > a2.length ? 1 : -1; 
     611    +/ 
     612    debug(adi) printf("adCmp()\n"); 
     613    auto len = a1.length; 
     614    if (a2.length < len) 
     615        len = a2.length; 
     616    auto sz = ti.tsize(); 
     617    void *p1 = a1.ptr; 
     618    void *p2 = a2.ptr; 
     619 
     620    if (sz == 1) 
     621    {   // We should really have a ti.isPOD() check for this 
     622        auto c = memcmp(p1, p2, len); 
     623        if (c) 
     624            return c; 
     625    } 
     626    else 
     627    { 
     628        for (size_t i = 0; i < len; i++) 
     629        { 
     630            auto c = ti.compare(p1 + i * sz, p2 + i * sz); 
     631            if (c) 
     632                return c; 
     633        } 
     634    } 
     635    if (a1.length == a2.length) 
     636        return 0; 
     637    return (a1.length > a2.length) ? 1 : -1; 
    585638} 
    586639