Remove unused interface

Comparing:
	old: v2-wip/17299c9 (2021-03-25 20:19:40 -0400 -0400)
	run: v2-wip/1da2fc7 (2021-03-25 20:38:05 -0400 -0400)
-----------------------------------------------------------
name                  old time/op    new time/op    delta
UnmarshalSimple/v2-8     755ns ± 3%     700ns ± 3%   -7.26%  (p=0.008 n=5+5)
UnmarshalSimple/v1-8    3.87µs ± 0%    3.85µs ± 1%     ~     (p=0.254 n=4+5)
UnmarshalSimple/bs-8    2.44µs ± 4%    2.34µs ± 2%     ~     (p=0.056 n=5+5)
ReferenceFile/v2-8      33.5µs ± 7%    32.2µs ±13%     ~     (p=0.421 n=5+5)
ReferenceFile/v1-8       269µs ± 3%     270µs ± 2%     ~     (p=1.000 n=5+5)
ReferenceFile/bs-8       296µs ± 2%     291µs ± 0%     ~     (p=0.095 n=5+5)

name                  old alloc/op   new alloc/op   delta
ReferenceFile/v2-8      38.9kB ± 0%    37.1kB ± 0%   -4.77%  (p=0.008 n=5+5)
ReferenceFile/v1-8       131kB ± 0%     131kB ± 0%     ~     (all equal)
ReferenceFile/bs-8      80.8kB ± 0%    80.8kB ± 0%     ~     (p=0.841 n=5+5)

name                  old allocs/op  new allocs/op  delta
ReferenceFile/v2-8         181 ± 0%       152 ± 0%  -16.02%  (p=0.008 n=5+5)
ReferenceFile/v1-8       2.65k ± 0%     2.65k ± 0%     ~     (all equal)
ReferenceFile/bs-8       1.73k ± 0%     1.73k ± 0%     ~     (all equal)
This commit is contained in:
Thomas Pelletier
2021-03-25 20:38:45 -04:00
parent 1da2fc7e28
commit 9d3a912da0
+10 -15
View File
@@ -12,20 +12,14 @@ import (
// for it.Next() {
// it.Node()
// }
type Iterator interface {
// Next moves the iterator forward and returns true if points to a node, false
// otherwise.
Next() bool
// Node returns a copy of the node pointed at by the iterator.
Node() Node
}
type chainIterator struct {
type Iterator struct {
started bool
node Node
}
func (c *chainIterator) Next() bool {
// Next moves the iterator forward and returns true if points to a node, false
// otherwise.
func (c *Iterator) Next() bool {
if !c.started {
c.started = true
} else if c.node.Valid() {
@@ -34,7 +28,8 @@ func (c *chainIterator) Next() bool {
return c.node.Valid()
}
func (c *chainIterator) Node() Node {
// Node returns a copy of the node pointed at by the iterator.
func (c *Iterator) Node() Node {
return c.node
}
@@ -43,7 +38,7 @@ type Root struct {
}
func (r *Root) Iterator() Iterator {
it := &chainIterator{}
it := Iterator{}
if len(r.nodes) > 0 {
it.node = r.nodes[0]
}
@@ -114,9 +109,9 @@ func (n *Node) Key() Iterator {
if !value.Valid() {
panic(fmt.Errorf("KeyValue should have at least two children"))
}
return &chainIterator{node: value.Next()}
return Iterator{node: value.Next()}
case Table, ArrayTable:
return &chainIterator{node: n.Child()}
return Iterator{node: n.Child()}
default:
panic(fmt.Errorf("Key() is not supported on a %s", n.Kind))
}
@@ -131,7 +126,7 @@ func (n Node) Value() Node {
}
func (n Node) Children() Iterator {
return &chainIterator{node: n.Child()}
return Iterator{node: n.Child()}
}
func assertKind(k Kind, n Node) {