]> Cypherpunks repositories - gostls13.git/commitdiff
interface equality (strings specifically)
authorKen Thompson <ken@golang.org>
Tue, 14 Oct 2008 23:10:44 +0000 (16:10 -0700)
committerKen Thompson <ken@golang.org>
Tue, 14 Oct 2008 23:10:44 +0000 (16:10 -0700)
R=r
OCL=17134
CL=17134

src/cmd/gc/walk.c
src/runtime/iface.c

index 47a3d10cb6c574c3fa29412454fa02e1b269965b..761a723dc861ca2256923c1e016815b8a1ea9b4c 100644 (file)
@@ -2572,9 +2572,7 @@ ifaceop(Type *tl, Node *n, int op)
                if(op == ONE)
                        r = nod(ONOT, r, N);
 
-               dump("bef", r);
                walktype(r, Erv);
-               dump("aft", r);
                return r;
        }
 
index b303e459e17a3b0add512e1fe6e9607647cde701..5ed40ce5396f56b0f396a7e651f7c98ea0743af1 100644 (file)
@@ -13,8 +13,8 @@ typedef       struct  Map     Map;
 struct Sigt
 {
        byte*   name;
-       uint32  hash;
-       uint32  offset;         // offset of substruct
+       uint32  hash;           // hash of type // first is alg
+       uint32  offset;         // offset of substruct // first is width
        void    (*fun)(void);
 };
 
@@ -265,6 +265,8 @@ sys·ifaceI2I(Sigi *si, Map *im, void *it, Map *retim, void *retit)
 void
 sys·ifaceeq(Map *im1, void *it1, Map *im2, void *it2, byte ret)
 {
+       int32 alg, wid;
+
        if(debug) {
                prints("Ieq i1=");
                printiface(im1, it1);
@@ -284,18 +286,17 @@ sys·ifaceeq(Map *im1, void *it1, Map *im2, void *it2, byte ret)
        if(im2 == nil)
                goto no;
 
-       // values
-       if(it1 != it2)
+       // value
+       alg = im1->sigt->hash;
+       if(alg != im2->sigt->hash)
                goto no;
 
-       // types
-       if(im1 == im2)
-               goto yes;
-       if(im1->sigt == im2->sigt)
-               goto yes;
-       if(im1->sigt->hash != im2->sigt->hash)
+       wid = im1->sigt->offset;
+       if(wid != im2->sigt->offset)
                goto no;
 
+       if(!algarray[alg].equal(wid, &it1, &it2))
+               goto no;
 
 yes:
        ret = true;