]> Cypherpunks repositories - gostls13.git/commitdiff
minor tweak to still non-portable alignment calculation
authorRob Pike <r@golang.org>
Wed, 5 Nov 2008 19:02:55 +0000 (11:02 -0800)
committerRob Pike <r@golang.org>
Wed, 5 Nov 2008 19:02:55 +0000 (11:02 -0800)
R=rsc
DELTA=4  (1 added, 1 deleted, 2 changed)
OCL=18528
CL=18533

src/lib/reflect/type.go

index 899b02f155061c873c4e28c50ffc666828fda78e..2c05901767f1fc0bdd5058cc09dfd199b00473c1 100644 (file)
@@ -289,12 +289,13 @@ func (t *StructTypeStruct) Size() int {
                return t.size
        }
        size := 0;
+       structalignmask := 7;   // BUG: we know structs are 8-aligned
        for i := 0; i < len(t.field); i++ {
                elemsize := t.field[i].typ.Get().Size();
                // pad until at (elemsize mod 8) boundary
                align := elemsize - 1;
-               if align > 7 {  // BUG: we know structs are 8-aligned
-                       align = 7
+               if align > structalignmask {
+                       align = structalignmask
                }
                if align > 0 {
                        size = (size + align) & ^align;
@@ -302,7 +303,6 @@ func (t *StructTypeStruct) Size() int {
                t.field[i].offset = size;
                size += elemsize;
        }
-       structalignmask := 7;   // TODO: knows that size fits in int32 (also can't use const here)
        size = (size + structalignmask) & ^(structalignmask);
        t.size = size;
        return size;