mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-07 02:15:34 +00:00
op, internal/ops: cleanups
Remove unnecessary fill when starting a recording in op.Record. Have the exact number of possible stack kinds in ops.Ops. Signed-off-by: Pierre Curto <pierre.curto@gmail.com>
This commit is contained in:
+4
-6
@@ -26,7 +26,7 @@ type Ops struct {
|
|||||||
multipOp bool
|
multipOp bool
|
||||||
|
|
||||||
macroStack stack
|
macroStack stack
|
||||||
stacks [5]stack
|
stacks [_StackKind]stack
|
||||||
}
|
}
|
||||||
|
|
||||||
type OpType byte
|
type OpType byte
|
||||||
@@ -80,7 +80,7 @@ type StackID struct {
|
|||||||
prev int
|
prev int
|
||||||
}
|
}
|
||||||
|
|
||||||
// StateOp represents a saved operation snapshop to be restored
|
// StateOp represents a saved operation snapshot to be restored
|
||||||
// later.
|
// later.
|
||||||
type StateOp struct {
|
type StateOp struct {
|
||||||
id int
|
id int
|
||||||
@@ -108,7 +108,7 @@ const (
|
|||||||
ClipStack StackKind = iota
|
ClipStack StackKind = iota
|
||||||
TransStack
|
TransStack
|
||||||
PassStack
|
PassStack
|
||||||
MetaStack
|
_StackKind
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@@ -180,9 +180,7 @@ func (op *ClipOp) Decode(data []byte) {
|
|||||||
|
|
||||||
func Reset(o *Ops) {
|
func Reset(o *Ops) {
|
||||||
o.macroStack = stack{}
|
o.macroStack = stack{}
|
||||||
for i := range o.stacks {
|
o.stacks = [_StackKind]stack{}
|
||||||
o.stacks[i] = stack{}
|
|
||||||
}
|
|
||||||
// Leave references to the GC.
|
// Leave references to the GC.
|
||||||
for i := range o.refs {
|
for i := range o.refs {
|
||||||
o.refs[i] = nil
|
o.refs[i] = nil
|
||||||
|
|||||||
@@ -153,8 +153,8 @@ func Record(o *Ops) MacroOp {
|
|||||||
pc: ops.PCFor(&o.Internal),
|
pc: ops.PCFor(&o.Internal),
|
||||||
}
|
}
|
||||||
// Reserve room for a macro definition. Updated in Stop.
|
// Reserve room for a macro definition. Updated in Stop.
|
||||||
ops.Write(m.ops, ops.TypeMacroLen)
|
data := ops.Write(m.ops, ops.TypeMacroLen)
|
||||||
m.fill()
|
data[0] = byte(ops.TypeMacro)
|
||||||
return m
|
return m
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -162,17 +162,13 @@ func Record(o *Ops) MacroOp {
|
|||||||
// operation for replaying it.
|
// operation for replaying it.
|
||||||
func (m MacroOp) Stop() CallOp {
|
func (m MacroOp) Stop() CallOp {
|
||||||
ops.PopMacro(m.ops, m.id)
|
ops.PopMacro(m.ops, m.id)
|
||||||
m.fill()
|
ops.FillMacro(m.ops, m.pc)
|
||||||
return CallOp{
|
return CallOp{
|
||||||
ops: m.ops,
|
ops: m.ops,
|
||||||
pc: m.pc,
|
pc: m.pc,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m MacroOp) fill() {
|
|
||||||
ops.FillMacro(m.ops, m.pc)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add the recorded list of operations. Add
|
// Add the recorded list of operations. Add
|
||||||
// panics if the Ops containing the recording
|
// panics if the Ops containing the recording
|
||||||
// has been reset.
|
// has been reset.
|
||||||
|
|||||||
Reference in New Issue
Block a user