-
Notifications
You must be signed in to change notification settings - Fork 844
Clean code and fix issues reported by staticcheck #223
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -413,6 +413,7 @@ func TestNodeSplit(t *testing.T) { | |
rt, err = mutable.Commit() | ||
require.NoError(t, err) | ||
rt, err = Load(cfg.Persister, rt.ID(), comparator) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we |
||
require.NoError(t, err) | ||
|
||
result, err = mutable.(*Tr).toList(itemsToValues(items...)...) | ||
require.NoError(t, err) | ||
|
@@ -505,6 +506,7 @@ func TestRandom(t *testing.T) { | |
require.NoError(t, err) | ||
expected := toOrdered(items).toItems() | ||
result, err := mutable.(*Tr).toList(itemsToValues(expected...)...) | ||
require.NoError(t, err) | ||
if !assert.Equal(t, expected, result) { | ||
assert.Equal(t, len(expected), len(result)) | ||
for i, c := range expected { | ||
|
@@ -763,10 +765,11 @@ func TestSecondCommitMultipleSplits(t *testing.T) { | |
mutable.AddItems(items[:25]...) | ||
mutable.(*Tr).verify(mutable.(*Tr).Root, t) | ||
rt, err := mutable.Commit() | ||
require.NoError(t, err) | ||
rt.(*Tr).verify(rt.(*Tr).Root, t) | ||
|
||
result, err := rt.(*Tr).toList(itemsToValues(items...)...) | ||
require.Nil(t, err) | ||
result, errToList := rt.(*Tr).toList(itemsToValues(items...)...) | ||
require.Nil(t, errToList) | ||
assert.Equal(t, items[:25], result) | ||
|
||
mutable = rt.AsMutable() | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -197,16 +197,11 @@ func BenchmarkGoMapExists(b *testing.B) { | |
|
||
b.ResetTimer() | ||
|
||
var ok bool | ||
for i := 0; i < b.N; i++ { | ||
for _, key := range keys { | ||
_, ok = hm[key] // or the compiler complains | ||
} | ||
for range keys { } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are we sure that the compiler is not going to drop this out? |
||
} | ||
|
||
b.StopTimer() | ||
if ok { // or the compiler complains | ||
} | ||
} | ||
|
||
func BenchmarkDelete(b *testing.B) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -203,19 +203,11 @@ func (irt *immutableRangeTree) apply(list orderedNodes, interval Interval, | |
low, high := interval.LowAtDimension(dimension), interval.HighAtDimension(dimension) | ||
|
||
if isLastDimension(irt.dimensions, dimension) { | ||
if !list.apply(low, high, fn) { | ||
return false | ||
} | ||
return list.apply(low, high, fn) | ||
} else { | ||
if !list.apply(low, high, func(n *node) bool { | ||
if !irt.apply(n.orderedNodes, interval, dimension+1, fn) { | ||
return false | ||
} | ||
return true | ||
}) { | ||
return false | ||
} | ||
return true | ||
return list.apply(low, high, func(n *node) bool { | ||
return irt.apply(n.orderedNodes, interval, dimension+1, fn) | ||
}) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We might simplify this further by moving this out of the |
||
} | ||
|
||
return true | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -183,19 +183,11 @@ func (ot *orderedTree) apply(list orderedNodes, interval Interval, | |
low, high := interval.LowAtDimension(dimension), interval.HighAtDimension(dimension) | ||
|
||
if isLastDimension(ot.dimensions, dimension) { | ||
if !list.apply(low, high, fn) { | ||
return false | ||
} | ||
return list.apply(low, high, fn) | ||
} else { | ||
if !list.apply(low, high, func(n *node) bool { | ||
if !ot.apply(n.orderedNodes, interval, dimension+1, fn) { | ||
return false | ||
} | ||
return true | ||
}) { | ||
return false | ||
} | ||
return true | ||
return list.apply(low, high, func(n *node) bool { | ||
return ot.apply(n.orderedNodes, interval, dimension+1, fn) | ||
}) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As in the |
||
} | ||
|
||
return true | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could assert on
err
to be complete.