mirror of
https://github.com/dolthub/dolt.git
synced 2026-02-11 18:49:14 -06:00
Remove more assertions which allocate in non-failure cases (#1942)
This commit is contained in:
@@ -148,7 +148,7 @@ func planWork(srcQ, sinkQ *types.RefHeap) (srcRefs, sinkRefs, comRefs types.RefS
|
||||
sinkRefs, comRefs = burnDown(sinkQ, srcQ, sinkHt, srcHt)
|
||||
return
|
||||
}
|
||||
d.Chk.True(srcHt == sinkHt, "%d != %d", srcHt, sinkHt)
|
||||
d.Chk.True(srcHt == sinkHt)
|
||||
srcRefs, comRefs = burnDown(srcQ, sinkQ, srcHt, sinkHt)
|
||||
sinkRefs, _ = burnDown(sinkQ, srcQ, sinkHt, srcHt)
|
||||
return
|
||||
@@ -169,7 +169,7 @@ func burnDown(taller, shorter *types.RefHeap, tall, short uint64) (tallRefs, com
|
||||
shortIdx++
|
||||
continue
|
||||
}
|
||||
d.Chk.True(tallRef.Equals(shortPeek), "Refs should be equal: %s != %s", tallRef.TargetHash(), shortPeek.TargetHash())
|
||||
d.Chk.True(tallRef.Equals(shortPeek))
|
||||
heap.Remove(shorter, shortIdx)
|
||||
comRefs = append(comRefs, tallRef)
|
||||
}
|
||||
|
||||
@@ -46,7 +46,6 @@ type orderedKey struct {
|
||||
}
|
||||
|
||||
func newOrderedKey(v Value) orderedKey {
|
||||
d.Chk.NotNil(v)
|
||||
if isKindOrderedByValue(v.Type().Kind()) {
|
||||
return orderedKey{true, v, hash.Hash{}}
|
||||
}
|
||||
|
||||
@@ -24,9 +24,9 @@ func (opCacheComparer) Compare(a, b []byte) int {
|
||||
return 1
|
||||
}
|
||||
a, b = a[1:], b[1:]
|
||||
d.Chk.True(len(a) == sha1.Size && len(b) == sha1.Size, "Compared objects should be %d bytes long, not %d and %d", sha1.Size, len(a), len(b))
|
||||
d.Chk.True(len(a) == sha1.Size && len(b) == sha1.Size)
|
||||
res := bytes.Compare(a, b)
|
||||
d.Chk.True(res != 0 || aKind == bKind, "%d != %d, but Values with the same hash MUST be the same Kind", aKind, bKind)
|
||||
d.Chk.True(res != 0 || aKind == bKind)
|
||||
return res
|
||||
case BoolKind:
|
||||
return bytes.Compare(a, b)
|
||||
|
||||
@@ -47,7 +47,7 @@ func NewStructWithType(t *Type, data structData) Struct {
|
||||
values := make([]Value, desc.Len())
|
||||
for i, field := range desc.fields {
|
||||
v, ok := data[field.name]
|
||||
d.Chk.True(ok, "Missing required field %s", field.name)
|
||||
d.Chk.True(ok)
|
||||
assertSubtype(field.t, v)
|
||||
values[i] = v
|
||||
}
|
||||
@@ -105,14 +105,14 @@ func (s Struct) MaybeGet(n string) (Value, bool) {
|
||||
}
|
||||
|
||||
func (s Struct) Get(n string) Value {
|
||||
f, i := s.desc().findField(n)
|
||||
d.Chk.True(i != -1, `Struct has no field "%s"`, f.name)
|
||||
_, i := s.desc().findField(n)
|
||||
d.Chk.True(i != -1, "Struct has no such field")
|
||||
return s.values[i]
|
||||
}
|
||||
|
||||
func (s Struct) Set(n string, v Value) Struct {
|
||||
f, i := s.desc().findField(n)
|
||||
d.Chk.True(i != -1, "Struct has no field %s", n)
|
||||
d.Chk.True(i != -1, "Struct has no such field")
|
||||
assertSubtype(f.t, v)
|
||||
values := make([]Value, len(s.values))
|
||||
copy(values, s.values)
|
||||
|
||||
Reference in New Issue
Block a user