aboutsummaryrefslogtreecommitdiffstats
path: root/pkg/compiler/gen.go
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/compiler/gen.go')
-rw-r--r--pkg/compiler/gen.go12
1 files changed, 3 insertions, 9 deletions
diff --git a/pkg/compiler/gen.go b/pkg/compiler/gen.go
index fb406b815..81e8f83bc 100644
--- a/pkg/compiler/gen.go
+++ b/pkg/compiler/gen.go
@@ -284,9 +284,7 @@ func (comp *compiler) layoutUnion(t *prog.UnionType) {
" which is less than field %v size %v",
structNode.Name.Name, sizeAttr, fld.Type.Name(), sz)
}
- if t.TypeSize < sz {
- t.TypeSize = sz
- }
+ t.TypeSize = max(t.TypeSize, sz)
}
if hasSize {
t.TypeSize = sizeAttr
@@ -313,9 +311,7 @@ func (comp *compiler) layoutStruct(t *prog.StructType) {
size = 0
}
size += f.Size()
- if t.TypeSize < size {
- t.TypeSize = size
- }
+ t.TypeSize = max(t.TypeSize, size)
}
sizeAttr, hasSize := attrs[attrSize]
if hasSize {
@@ -348,9 +344,7 @@ func (comp *compiler) layoutStructFields(t *prog.StructType, varlen, packed bool
fieldAlign := uint64(1)
if !packed {
fieldAlign = f.Alignment()
- if structAlign < fieldAlign {
- structAlign = fieldAlign
- }
+ structAlign = max(structAlign, fieldAlign)
}
fullBitOffset := byteOffset*8 + bitOffset
var fieldOffset uint64