Quieten deadcode

This commit is contained in:
kortschak 2014-08-28 12:04:45 +09:30
parent 484bf145a8
commit 8118c8d3cc
11 changed files with 25 additions and 37 deletions

View file

@ -503,5 +503,5 @@ func compareTokens(a, b graph.Value) bool {
}
func (qs *QuadStore) FixedIterator() graph.FixedIterator {
return iterator.NewFixedIteratorWithCompare(compareTokens)
return iterator.NewFixed(compareTokens)
}

View file

@ -27,7 +27,7 @@ import (
func TestIteratorPromotion(t *testing.T) {
all := NewInt64(1, 3)
fixed := newFixed()
fixed := NewFixed(Identity)
fixed.Add(3)
a := NewAnd()
a.AddSubIterator(all)

View file

@ -22,7 +22,7 @@ import (
// Make sure that tags work on the And.
func TestTag(t *testing.T) {
fix1 := newFixed()
fix1 := NewFixed(Identity)
fix1.Add(234)
fix1.Tagger().Add("foo")
and := NewAnd()
@ -55,12 +55,12 @@ func TestTag(t *testing.T) {
// Do a simple itersection of fixed values.
func TestAndAndFixedIterators(t *testing.T) {
fix1 := newFixed()
fix1 := NewFixed(Identity)
fix1.Add(1)
fix1.Add(2)
fix1.Add(3)
fix1.Add(4)
fix2 := newFixed()
fix2 := NewFixed(Identity)
fix2.Add(3)
fix2.Add(4)
fix2.Add(5)
@ -93,12 +93,12 @@ func TestAndAndFixedIterators(t *testing.T) {
// If there's no intersection, the size should still report the same,
// but there should be nothing to Next()
func TestNonOverlappingFixedIterators(t *testing.T) {
fix1 := newFixed()
fix1 := NewFixed(Identity)
fix1.Add(1)
fix1.Add(2)
fix1.Add(3)
fix1.Add(4)
fix2 := newFixed()
fix2 := NewFixed(Identity)
fix2.Add(5)
fix2.Add(6)
fix2.Add(7)

View file

@ -42,24 +42,16 @@ type Fixed struct {
type Equality func(a, b graph.Value) bool
// Define an equality function of purely ==, which works for native types.
func BasicEquality(a, b graph.Value) bool {
if a == b {
return true
}
return false
func Identity(a, b graph.Value) bool {
return a == b
}
// Creates a new Fixed iterator based around == equality.
func newFixed() *Fixed {
return NewFixedIteratorWithCompare(BasicEquality)
}
// Creates a new Fixed iterator with a custom comparitor.
func NewFixedIteratorWithCompare(compareFn Equality) *Fixed {
// Creates a new Fixed iterator with a custom comparator.
func NewFixed(cmp Equality) *Fixed {
return &Fixed{
uid: NextUID(),
values: make([]graph.Value, 0, 20),
cmp: compareFn,
cmp: cmp,
}
}
@ -88,7 +80,7 @@ func (it *Fixed) TagResults(dst map[string]graph.Value) {
}
func (it *Fixed) Clone() graph.Iterator {
out := NewFixedIteratorWithCompare(it.cmp)
out := NewFixed(it.cmp)
for _, val := range it.values {
out.Add(val)
}

View file

@ -23,10 +23,10 @@ import (
func TestLinksTo(t *testing.T) {
qs := &store{
data: []string{1: "cool"},
iter: newFixed(),
iter: NewFixed(Identity),
}
qs.iter.(*Fixed).Add(2)
fixed := newFixed()
fixed := NewFixed(Identity)
val := qs.ValueOf("cool")
if val != 1 {
t.Fatalf("Failed to return correct value, got:%v expect:1", val)

View file

@ -65,7 +65,7 @@ func (qs *store) OptimizeIterator(it graph.Iterator) (graph.Iterator, bool) {
}
func (qs *store) FixedIterator() graph.FixedIterator {
return NewFixedIteratorWithCompare(BasicEquality)
return NewFixed(Identity)
}
func (qs *store) Close() {}

View file

@ -31,11 +31,11 @@ func iterated(it graph.Iterator) []int {
func TestOrIteratorBasics(t *testing.T) {
or := NewOr()
f1 := newFixed()
f1 := NewFixed(Identity)
f1.Add(1)
f1.Add(2)
f1.Add(3)
f2 := newFixed()
f2 := NewFixed(Identity)
f2.Add(3)
f2.Add(9)
f2.Add(20)
@ -77,11 +77,11 @@ func TestOrIteratorBasics(t *testing.T) {
func TestShortCircuitingOrBasics(t *testing.T) {
var or *Or
f1 := newFixed()
f1 := NewFixed(Identity)
f1.Add(1)
f1.Add(2)
f1.Add(3)
f2 := newFixed()
f2 := NewFixed(Identity)
f2.Add(3)
f2.Add(9)
f2.Add(20)
@ -133,7 +133,7 @@ func TestShortCircuitingOrBasics(t *testing.T) {
// Check that it pulls the second iterator's numbers if the first is empty.
or = NewShortCircuitOr()
or.AddSubIterator(newFixed())
or.AddSubIterator(NewFixed(Identity))
or.AddSubIterator(f2)
expect = []int{3, 9, 20, 21}
for i := 0; i < 2; i++ {

View file

@ -24,7 +24,7 @@ import (
var simpleStore = &store{data: []string{"0", "1", "2", "3", "4", "5"}}
func simpleFixedIterator() *Fixed {
f := newFixed()
f := NewFixed(Identity)
for i := 0; i < 5; i++ {
f.Add(i)
}

View file

@ -480,5 +480,5 @@ func compareBytes(a, b graph.Value) bool {
}
func (qs *QuadStore) FixedIterator() graph.FixedIterator {
return iterator.NewFixedIteratorWithCompare(compareBytes)
return iterator.NewFixed(compareBytes)
}

View file

@ -235,7 +235,7 @@ func (qs *QuadStore) QuadsAllIterator() graph.Iterator {
}
func (qs *QuadStore) FixedIterator() graph.FixedIterator {
return iterator.NewFixedIteratorWithCompare(iterator.BasicEquality)
return iterator.NewFixed(iterator.Identity)
}
func (qs *QuadStore) QuadDirection(val graph.Value, d quad.Direction) graph.Value {

View file

@ -327,12 +327,8 @@ func (qs *QuadStore) Horizon() int64 {
return log.LogID
}
func compareStrings(a, b graph.Value) bool {
return a.(string) == b.(string)
}
func (qs *QuadStore) FixedIterator() graph.FixedIterator {
return iterator.NewFixedIteratorWithCompare(compareStrings)
return iterator.NewFixed(iterator.Identity)
}
func (qs *QuadStore) Close() {