Skip to content

Commit 92bb933

Browse files
committed
Clean up
1 parent 8ec0479 commit 92bb933

File tree

15 files changed

+55
-64
lines changed

15 files changed

+55
-64
lines changed

fieldpath/fromvalue.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ func SetFromValue(v value.Value) *Set {
2727
w := objectWalker{
2828
path: Path{},
2929
value: v,
30-
allocator: value.NewValueFreelist(),
30+
allocator: value.NewFreelistAllocator(),
3131
do: func(p Path) { s.Insert(p) },
3232
}
3333

@@ -38,7 +38,7 @@ func SetFromValue(v value.Value) *Set {
3838
type objectWalker struct {
3939
path Path
4040
value value.Value
41-
allocator *value.ValueFreelist
41+
allocator value.Allocator
4242

4343
do func(Path)
4444
}

typed/helpers.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ func setItemToPathElement(list *schema.List, index int, child value.Value) (fiel
225225
}
226226
}
227227

228-
func listItemToPathElement(a *value.ValueFreelist, list *schema.List, index int, child value.Value) (fieldpath.PathElement, error) {
228+
func listItemToPathElement(a value.Allocator, list *schema.List, index int, child value.Value) (fieldpath.PathElement, error) {
229229
if list.ElementRelationship == schema.Associative {
230230
if len(list.Keys) > 0 {
231231
return keyedAssociativeListItemToPathElement(a, list, index, child)

typed/merge.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ type mergingWalker struct {
4949
// Allocate only as many walkers as needed for the depth by storing them here.
5050
spareWalkers *[]*mergingWalker
5151

52-
allocator *value.ValueFreelist
52+
allocator value.Allocator
5353
}
5454

5555
// merge rules examine w.lhs and w.rhs (up to one of which may be nil) and

typed/remove.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,15 @@ type removingWalker struct {
2424
out interface{}
2525
schema *schema.Schema
2626
toRemove *fieldpath.Set
27-
allocator *value.ValueFreelist
27+
allocator value.Allocator
2828
}
2929

3030
func removeItemsWithSchema(val value.Value, toRemove *fieldpath.Set, schema *schema.Schema, typeRef schema.TypeRef) value.Value {
3131
w := &removingWalker{
3232
value: val,
3333
schema: schema,
3434
toRemove: toRemove,
35-
allocator: value.NewValueFreelist(),
35+
allocator: value.NewFreelistAllocator(),
3636
}
3737
resolveSchema(schema, typeRef, val, w)
3838
return value.NewValueInterface(w.out)

typed/tofieldset.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ func (tv TypedValue) toFieldSetWalker() *toFieldSetWalker {
3434
v.schema = tv.schema
3535
v.typeRef = tv.typeRef
3636
v.set = &fieldpath.Set{}
37-
v.allocator = value.NewValueFreelist()
37+
v.allocator = value.NewFreelistAllocator()
3838
return v
3939
}
4040

@@ -56,7 +56,7 @@ type toFieldSetWalker struct {
5656

5757
// Allocate only as many walkers as needed for the depth by storing them here.
5858
spareWalkers *[]*toFieldSetWalker
59-
allocator *value.ValueFreelist
59+
allocator value.Allocator
6060
}
6161

6262
func (v *toFieldSetWalker) prepareDescent(pe fieldpath.PathElement, tr schema.TypeRef) *toFieldSetWalker {

typed/typed.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ func merge(lhs, rhs *TypedValue, rule, postRule mergeRule) (*TypedValue, error)
239239
mw.rule = rule
240240
mw.postItemHook = postRule
241241
if mw.allocator == nil {
242-
mw.allocator = value.NewValueFreelist()
242+
mw.allocator = value.NewFreelistAllocator()
243243
}
244244

245245
errs := mw.merge(nil)

typed/validate.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ func (tv TypedValue) walker() *validatingObjectWalker {
3434
v.schema = tv.schema
3535
v.typeRef = tv.typeRef
3636
if v.allocator == nil {
37-
v.allocator = value.NewValueFreelist()
37+
v.allocator = value.NewFreelistAllocator()
3838
}
3939
return v
4040
}
@@ -52,7 +52,7 @@ type validatingObjectWalker struct {
5252

5353
// Allocate only as many walkers as needed for the depth by storing them here.
5454
spareWalkers *[]*validatingObjectWalker
55-
allocator *value.ValueFreelist
55+
allocator value.Allocator
5656
}
5757

5858
func (v *validatingObjectWalker) prepareDescent(tr schema.TypeRef) *validatingObjectWalker {

value/list.go

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ type ListRange interface {
4141
// Item returns the index and value of the current item in the range. or panics if there is no current item.
4242
// For efficiency, Item may reuse the values returned by previous Item calls. Callers should be careful avoid holding
4343
// pointers to the value returned by Item() that escape the iteration loop since they become invalid once either
44-
// Item() or Recycle() is called.
44+
// Item() or Allocator.Free() is called.
4545
Item() (index int, value Value)
4646
}
4747

@@ -57,15 +57,13 @@ func (_ *emptyRange) Item() (index int, value Value) {
5757
panic("Item called on empty ListRange")
5858
}
5959

60-
func (_ *emptyRange) Recycle() {}
61-
6260
// ListEquals compares two lists lexically.
6361
// WARN: This is a naive implementation, calling lhs.Equals(rhs) is typically the most efficient.
6462
func ListEquals(lhs, rhs List) bool {
65-
return listEqualsInto(defaultAllocator, lhs, rhs)
63+
return ListEqualsInto(defaultAllocator, lhs, rhs)
6664
}
6765

68-
func listEqualsInto(a Allocator, lhs, rhs List) bool {
66+
func ListEqualsInto(a Allocator, lhs, rhs List) bool {
6967
if lhs.Length() != rhs.Length() {
7068
return false
7169
}
@@ -78,7 +76,7 @@ func listEqualsInto(a Allocator, lhs, rhs List) bool {
7876
for lhsRange.Next() && rhsRange.Next() {
7977
_, lv := lhsRange.Item()
8078
_, rv := rhsRange.Item()
81-
if !equalsInto(a, lv, rv) {
79+
if !EqualsInto(a, lv, rv) {
8280
return false
8381
}
8482
}
@@ -93,9 +91,9 @@ func ListLess(lhs, rhs List) bool {
9391
// ListCompare compares two lists lexically. The result will be 0 if l==rhs, -1
9492
// if l < rhs, and +1 if l > rhs.
9593
func ListCompare(lhs, rhs List) int {
96-
return listCompareInto(defaultAllocator, lhs, rhs)
94+
return ListCompareInto(defaultAllocator, lhs, rhs)
9795
}
98-
func listCompareInto(a Allocator, lhs, rhs List) int {
96+
func ListCompareInto(a Allocator, lhs, rhs List) int {
9997
lhsRange := lhs.RangeInto(a)
10098
defer a.Free(lhsRange)
10199
rhsRange := rhs.RangeInto(a)
@@ -118,7 +116,7 @@ func listCompareInto(a Allocator, lhs, rhs List) int {
118116
}
119117
_, lv := lhsRange.Item()
120118
_, rv := rhsRange.Item()
121-
if c := compareInto(a, lv, rv); c != 0 {
119+
if c := CompareInto(a, lv, rv); c != 0 {
122120
return c
123121
}
124122
// The items are equal; continue.

value/listreflect.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ func (r listReflect) EqualsInto(a Allocator, other List) bool {
7171
if otherReflectList, ok := other.(*listReflect); ok {
7272
return reflect.DeepEqual(r.Value.Interface(), otherReflectList.Value.Interface())
7373
}
74-
return listEqualsInto(a, &r, other)
74+
return ListEqualsInto(a, &r, other)
7575
}
7676

7777
type listReflectRange struct {

value/listunstructured.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ func (l listUnstructured) Equals(other List) bool {
3535
}
3636

3737
func (l listUnstructured) EqualsInto(a Allocator, other List) bool {
38-
return listEqualsInto(a, &l, other)
38+
return ListEqualsInto(a, &l, other)
3939
}
4040

4141
func (l listUnstructured) Range() ListRange {

0 commit comments

Comments
 (0)