diff --git a/go/libraries/doltcore/schema/typeinfo/common_test.go b/go/libraries/doltcore/schema/typeinfo/common_test.go index 39052ed6b8b..3c3df0dac6a 100644 --- a/go/libraries/doltcore/schema/typeinfo/common_test.go +++ b/go/libraries/doltcore/schema/typeinfo/common_test.go @@ -27,7 +27,6 @@ import ( "github.com/dolthub/vitess/go/sqltypes" "github.com/stretchr/testify/require" - "github.com/dolthub/dolt/go/libraries/utils/mathutil" "github.com/dolthub/dolt/go/store/types" ) @@ -184,7 +183,7 @@ func mustBlobBytes(t *testing.T, b []byte) types.Blob { func loop(t *testing.T, start int64, endInclusive int64, numOfSteps uint16, loopedFunc func(int64)) { require.True(t, endInclusive > start) maxNumOfSteps := endInclusive - start + 1 - trueNumOfSteps := mathutil.MinInt64(int64(numOfSteps), maxNumOfSteps) - 1 + trueNumOfSteps := min(int64(numOfSteps), maxNumOfSteps) - 1 inc := float64(maxNumOfSteps) / float64(trueNumOfSteps) fCurrentVal := float64(start) currentVal := int64(math.Round(fCurrentVal)) diff --git a/go/libraries/doltcore/sqle/index/dolt_map_iter.go b/go/libraries/doltcore/sqle/index/dolt_map_iter.go index aca8a9a7ea8..7a21f312769 100644 --- a/go/libraries/doltcore/sqle/index/dolt_map_iter.go +++ b/go/libraries/doltcore/sqle/index/dolt_map_iter.go @@ -25,14 +25,6 @@ import ( "github.com/dolthub/dolt/go/store/types" ) -func maxU64(x, y uint64) uint64 { - if x > y { - return x - } - - return y -} - // KVToSqlRowConverter takes noms types.Value key value pairs and converts them directly to a sql.Row. It // can be configured to only process a portion of the columns and map columns to desired output columns. type KVToSqlRowConverter struct { @@ -73,7 +65,7 @@ func getValLocations(tagToSqlColIdx map[uint64]int, cols []schema.Column) (int, fromKey++ } else { fromVal++ - maxValTag = maxU64(maxValTag, col.Tag) + maxValTag = max(maxValTag, col.Tag) } } } diff --git a/go/libraries/doltcore/table/untyped/tabular/stringwidth.go b/go/libraries/doltcore/table/untyped/tabular/stringwidth.go index eeb224014ee..2ea6a53ab26 100644 --- a/go/libraries/doltcore/table/untyped/tabular/stringwidth.go +++ b/go/libraries/doltcore/table/untyped/tabular/stringwidth.go @@ -101,10 +101,3 @@ func ColoredStringWidth(coloredText string, uncoloredText string) FixedWidthStri } return uncolored } - -func min(x, y int) int { - if x < y { - return x - } - return y -} diff --git a/go/libraries/utils/iohelp/read_test.go b/go/libraries/utils/iohelp/read_test.go index ae0c7a84b4e..5947e1743b3 100644 --- a/go/libraries/utils/iohelp/read_test.go +++ b/go/libraries/utils/iohelp/read_test.go @@ -25,7 +25,6 @@ import ( "github.com/stretchr/testify/assert" - "github.com/dolthub/dolt/go/libraries/utils/mathutil" "github.com/dolthub/dolt/go/libraries/utils/osutil" "github.com/dolthub/dolt/go/libraries/utils/test" ) @@ -150,7 +149,7 @@ func (gen *FixedRateDataGenerator) Read(p []byte) (int, error) { case <-time.After(nextRead): gen.dataGenerated += uint64(gen.BytesPerInterval) gen.lastRead = time.Now() - return mathutil.Min(gen.BytesPerInterval, len(p)), nil + return min(gen.BytesPerInterval, len(p)), nil } } diff --git a/go/libraries/utils/mathutil/max.go b/go/libraries/utils/mathutil/max.go deleted file mode 100644 index 30e51a0f3a6..00000000000 --- a/go/libraries/utils/mathutil/max.go +++ /dev/null @@ -1,114 +0,0 @@ -// Copyright 2019 Dolthub, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package mathutil - -var Max = MaxInt // alias -var Min = MinInt // alias - -func MaxInt(a, b int) int { - if a > b { - return a - } else { - return b - } -} - -func MinInt(a, b int) int { - if a < b { - return a - } else { - return b - } -} - -func MaxInt64(a, b int64) int64 { - if a > b { - return a - } else { - return b - } -} - -func MinInt64(a, b int64) int64 { - if a < b { - return a - } else { - return b - } -} - -func MaxUint(a, b uint) uint { - if a > b { - return a - } else { - return b - } -} - -func MinUint(a, b uint) uint { - if a < b { - return a - } else { - return b - } -} - -func MaxUint64(a, b uint64) uint64 { - if a > b { - return a - } else { - return b - } -} - -func MinUint64(a, b uint64) uint64 { - if a < b { - return a - } else { - return b - } -} - -func MaxFloat(a, b float32) float32 { - if a > b { - return a - } else { - return b - } -} - -func MinFloat(a, b float32) float32 { - if a < b { - return a - } else { - return b - } -} - -func MaxFloat64(a, b float64) float64 { - if a > b { - return a - } else { - return b - } -} - -func MinFloat64(a, b float64) float64 { - if a < b { - return a - } else { - return b - } -} diff --git a/go/libraries/utils/mathutil/max_test.go b/go/libraries/utils/mathutil/max_test.go deleted file mode 100644 index 1ff5e8657c9..00000000000 --- a/go/libraries/utils/mathutil/max_test.go +++ /dev/null @@ -1,65 +0,0 @@ -// Copyright 2019 Dolthub, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package mathutil - -import "testing" - -func TestMax(t *testing.T) { - if MaxInt(1, 2) != 2 || MaxInt(2, 1) != 2 { - t.Error("MaxInt error") - } - if Max(1, 2) != 2 || Max(2, 1) != 2 { - t.Error("Max error") - } - if MaxInt64(1, 2) != 2 || MaxInt64(2, 1) != 2 { - t.Error("MaxInt64 error") - } - if MaxFloat(1, 2) != 2 || MaxFloat(2, 1) != 2 { - t.Error("MaxFloat error") - } - if MaxFloat64(1, 2) != 2 || MaxFloat64(2, 1) != 2 { - t.Error("MaxFloat64 error") - } - if MaxUint(1, 2) != 2 || MaxUint(2, 1) != 2 { - t.Error("MaxUint error") - } - if MaxUint64(1, 2) != 2 || MaxUint64(2, 1) != 2 { - t.Error("MaxUint error") - } -} - -func TestMin(t *testing.T) { - if MinInt(1, 2) != 1 || MinInt(2, 1) != 1 { - t.Error("MinInt error") - } - if Min(1, 2) != 1 || Min(2, 1) != 1 { - t.Error("Min error") - } - if MinInt64(1, 2) != 1 || MinInt64(2, 1) != 1 { - t.Error("MinInt64 error") - } - if MinFloat(1, 2) != 1 || MinFloat(2, 1) != 1 { - t.Error("MinFloat error") - } - if MinFloat64(1, 2) != 1 || MinFloat64(2, 1) != 1 { - t.Error("MinFloat64 error") - } - if MinUint(1, 2) != 1 || MinUint(2, 1) != 1 { - t.Error("MaxUint error") - } - if MinUint64(1, 2) != 1 || MinUint64(2, 1) != 1 { - t.Error("MaxUint error") - } -} diff --git a/go/store/blobstore/gcs.go b/go/store/blobstore/gcs.go index 12f92494727..f6bffcb7329 100644 --- a/go/store/blobstore/gcs.go +++ b/go/store/blobstore/gcs.go @@ -232,12 +232,3 @@ func (bs *GCSBlobstore) composeObjects(ctx context.Context, composite string, so func fmtGeneration(g int64) string { return strconv.FormatInt(g, 16) } - -func min(l, r int) (m int) { - if l < r { - m = l - } else { - m = r - } - return -} diff --git a/go/store/cmd/noms/noms_cat.go b/go/store/cmd/noms/noms_cat.go index 787b30f7585..c687c40967a 100644 --- a/go/store/cmd/noms/noms_cat.go +++ b/go/store/cmd/noms/noms_cat.go @@ -342,20 +342,6 @@ func hexStr(bytes []byte) string { const bytesPerRow = 16 -func max(i, j int) int { - if i > j { - return i - } - return j -} - -func min(i, j int) int { - if i < j { - return i - } - return j -} - func hexView(bytes []byte, indent string) string { str := "" for i := 0; i < len(bytes); i += bytesPerRow { diff --git a/go/store/types/blob.go b/go/store/types/blob.go index 8e32b529555..1c9baa559c4 100644 --- a/go/store/types/blob.go +++ b/go/store/types/blob.go @@ -29,8 +29,6 @@ import ( "runtime" "sync" - "github.com/dolthub/dolt/go/libraries/utils/mathutil" - "github.com/dolthub/dolt/go/store/atomicerr" "github.com/dolthub/dolt/go/store/d" ) @@ -81,7 +79,7 @@ func (b Blob) Compare(ctx context.Context, nbf *NomsBinFormat, other LesserValua var b2Array [maxSliceSize]byte length := uint64(0) for i := uint64(0); i < minBlobLength; i += length { - length = mathutil.MinUint64(maxSliceSize, minBlobLength-i) + length = min(maxSliceSize, minBlobLength-i) b1Data := b1Array[:length] b2Data := b2Array[:length] n1, err := b1Reader.Read(b1Data) diff --git a/go/store/types/edit_distance.go b/go/store/types/edit_distance.go index e2bf7484fce..1a6171bea89 100644 --- a/go/store/types/edit_distance.go +++ b/go/store/types/edit_distance.go @@ -54,26 +54,6 @@ func (s Splice) String() string { return fmt.Sprintf("[%d, %d, %d, %d]", s.SpAt, s.SpRemoved, s.SpAdded, s.SpFrom) } -func uint64Min(a, b uint64) uint64 { - if a < b { - return a - } - return b -} - -func uint64Min3(a, b, c uint64) uint64 { - if a < b { - if a < c { - return a - } - } else { - if b < c { - return b - } - } - return c -} - func reverse(numbers []uint64) []uint64 { newNumbers := make([]uint64, len(numbers)) for i := 0; i < len(numbers); i++ { @@ -91,7 +71,7 @@ func addSplice(splices []Splice, s Splice) []Splice { } func calcSplices(previousLength uint64, currentLength uint64, maxSpliceMatrixSize uint64, eqFn EditDistanceEqualsFn) ([]Splice, error) { - minLength := uint64Min(previousLength, currentLength) + minLength := min(previousLength, currentLength) prefixCount, err := sharedPrefix(eqFn, minLength) if err != nil { @@ -227,7 +207,7 @@ func calcEditDistances(eqFn EditDistanceEqualsFn, previousStart uint64, previous } else { north := distances[i-1][j] + 1 west := distances[i][j-1] + 1 - distances[i][j] = uint64Min(north, west) + distances[i][j] = min(north, west) } } } @@ -255,7 +235,7 @@ func operationsFromEditDistances(distances [][]uint64) []uint64 { west := distances[i-1][j] north := distances[i][j-1] - minValue := uint64Min3(west, north, northWest) + minValue := min(west, north, northWest) if minValue == northWest { if northWest == current {