mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-05 01:15:35 +00:00
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:
+6
-15
@@ -168,21 +168,12 @@ func (op *ClipOp) Decode(data []byte) {
|
|||||||
}
|
}
|
||||||
data = data[:TypeClipLen]
|
data = data[:TypeClipLen]
|
||||||
bo := binary.LittleEndian
|
bo := binary.LittleEndian
|
||||||
r := image.Rectangle{
|
op.Bounds.Min.X = int(int32(bo.Uint32(data[1:])))
|
||||||
Min: image.Point{
|
op.Bounds.Min.Y = int(int32(bo.Uint32(data[5:])))
|
||||||
X: int(int32(bo.Uint32(data[1:]))),
|
op.Bounds.Max.X = int(int32(bo.Uint32(data[9:])))
|
||||||
Y: int(int32(bo.Uint32(data[5:]))),
|
op.Bounds.Max.Y = int(int32(bo.Uint32(data[13:])))
|
||||||
},
|
op.Outline = data[17] == 1
|
||||||
Max: image.Point{
|
op.Shape = Shape(data[18])
|
||||||
X: int(int32(bo.Uint32(data[9:]))),
|
|
||||||
Y: int(int32(bo.Uint32(data[13:]))),
|
|
||||||
},
|
|
||||||
}
|
|
||||||
*op = ClipOp{
|
|
||||||
Bounds: r,
|
|
||||||
Outline: data[17] == 1,
|
|
||||||
Shape: Shape(data[18]),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func Reset(o *Ops) {
|
func Reset(o *Ops) {
|
||||||
|
|||||||
+8
-19
@@ -165,14 +165,8 @@ func (op *opMacroDef) decode(data []byte) {
|
|||||||
}
|
}
|
||||||
bo := binary.LittleEndian
|
bo := binary.LittleEndian
|
||||||
data = data[:TypeMacroLen]
|
data = data[:TypeMacroLen]
|
||||||
dataIdx := int(int32(bo.Uint32(data[1:])))
|
op.endpc.data = int(int32(bo.Uint32(data[1:])))
|
||||||
refsIdx := int(int32(bo.Uint32(data[5:])))
|
op.endpc.refs = int(int32(bo.Uint32(data[5:])))
|
||||||
*op = opMacroDef{
|
|
||||||
endpc: PC{
|
|
||||||
data: dataIdx,
|
|
||||||
refs: refsIdx,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *macroOp) decode(data []byte, refs []interface{}) {
|
func (m *macroOp) decode(data []byte, refs []interface{}) {
|
||||||
@@ -181,15 +175,10 @@ func (m *macroOp) decode(data []byte, refs []interface{}) {
|
|||||||
}
|
}
|
||||||
bo := binary.LittleEndian
|
bo := binary.LittleEndian
|
||||||
data = data[:TypeCallLen]
|
data = data[:TypeCallLen]
|
||||||
*m = macroOp{
|
|
||||||
ops: refs[0].(*Ops),
|
m.ops = refs[0].(*Ops)
|
||||||
start: PC{
|
m.start.data = int(int32(bo.Uint32(data[1:])))
|
||||||
data: int(int32(bo.Uint32(data[1:]))),
|
m.start.refs = int(int32(bo.Uint32(data[5:])))
|
||||||
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:])))
|
||||||
end: PC{
|
|
||||||
data: int(int32(bo.Uint32(data[9:]))),
|
|
||||||
refs: int(int32(bo.Uint32(data[13:]))),
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user