internal/ops: optimize Decode

Using clean struct creation creates a lot of temporary variables in
assembly. Inline the assignments, which generates less code.

Signed-off-by: Egon Elbre <egonelbre@gmail.com>
This commit is contained in:
Egon Elbre
2022-07-02 16:39:16 +03:00
committed by Elias Naur
parent 17f604fb50
commit f8f68a4e9f
2 changed files with 14 additions and 34 deletions
+8 -19
View File
@@ -165,14 +165,8 @@ func (op *opMacroDef) decode(data []byte) {
}
bo := binary.LittleEndian
data = data[:TypeMacroLen]
dataIdx := int(int32(bo.Uint32(data[1:])))
refsIdx := int(int32(bo.Uint32(data[5:])))
*op = opMacroDef{
endpc: PC{
data: dataIdx,
refs: refsIdx,
},
}
op.endpc.data = int(int32(bo.Uint32(data[1:])))
op.endpc.refs = int(int32(bo.Uint32(data[5:])))
}
func (m *macroOp) decode(data []byte, refs []interface{}) {
@@ -181,15 +175,10 @@ func (m *macroOp) decode(data []byte, refs []interface{}) {
}
bo := binary.LittleEndian
data = data[:TypeCallLen]
*m = macroOp{
ops: refs[0].(*Ops),
start: PC{
data: int(int32(bo.Uint32(data[1:]))),
refs: int(int32(bo.Uint32(data[5:]))),
},
end: PC{
data: int(int32(bo.Uint32(data[9:]))),
refs: int(int32(bo.Uint32(data[13:]))),
},
}
m.ops = refs[0].(*Ops)
m.start.data = int(int32(bo.Uint32(data[1:])))
m.start.refs = int(int32(bo.Uint32(data[5:])))
m.end.data = int(int32(bo.Uint32(data[9:])))
m.end.refs = int(int32(bo.Uint32(data[13:])))
}