Commit 0d8e88fa authored by Kirill Smelkov's avatar Kirill Smelkov Committed by Kamil Kisiel

decoder: Use .push instead of open-coded .stack append where appropriate

For example

	d.push(math.Float64frombits(u))

looks more clear compared to

	d.stack = append(d.stack, math.Float64frombits(u))

and we already use push in many other places.
parent f04563c4
...@@ -579,7 +579,7 @@ func (d *Decoder) reduce() error { ...@@ -579,7 +579,7 @@ func (d *Decoder) reduce() error {
if !ok { if !ok {
return fmt.Errorf("pickle: reduce: invalid class: %T", xclass) return fmt.Errorf("pickle: reduce: invalid class: %T", xclass)
} }
d.stack = append(d.stack, Call{Callable: class, Args: args}) d.push(Call{Callable: class, Args: args})
return nil return nil
} }
...@@ -743,7 +743,7 @@ func (d *Decoder) global() error { ...@@ -743,7 +743,7 @@ func (d *Decoder) global() error {
return err return err
} }
sname := string(name) sname := string(name)
d.stack = append(d.stack, Class{Module: smodule, Name: sname}) d.push(Class{Module: smodule, Name: sname})
return nil return nil
} }
...@@ -999,7 +999,7 @@ func (d *Decoder) binFloat() error { ...@@ -999,7 +999,7 @@ func (d *Decoder) binFloat() error {
return err return err
} }
u := binary.BigEndian.Uint64(b[:]) u := binary.BigEndian.Uint64(b[:])
d.stack = append(d.stack, math.Float64frombits(u)) d.push(math.Float64frombits(u))
return nil return nil
} }
...@@ -1046,7 +1046,7 @@ func (d *Decoder) stackGlobal() error { ...@@ -1046,7 +1046,7 @@ func (d *Decoder) stackGlobal() error {
return fmt.Errorf("pickle: stackGlobal: invalid module: %T", xmodule) return fmt.Errorf("pickle: stackGlobal: invalid module: %T", xmodule)
} }
d.stack = append(d.stack, Class{Module: module, Name: name}) d.push(Class{Module: module, Name: name})
return nil return nil
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment