diff --git a/vendor/github.com/klauspost/reedsolomon/matrix.go b/vendor/github.com/klauspost/reedsolomon/matrix.go index e4b374830..1a59bc170 100644 --- a/vendor/github.com/klauspost/reedsolomon/matrix.go +++ b/vendor/github.com/klauspost/reedsolomon/matrix.go @@ -178,10 +178,7 @@ func (m matrix) SwapRows(r1, r2 int) error { // IsSquare will return true if the matrix is square // and nil if the matrix is square func (m matrix) IsSquare() bool { - if len(m) != len(m[0]) { - return false - } - return true + return len(m) == len(m[0]) } // errSingular is returned if the matrix is singular and cannot be inversed diff --git a/vendor/github.com/klauspost/reedsolomon/reedsolomon.go b/vendor/github.com/klauspost/reedsolomon/reedsolomon.go index 6cd3ccabf..3fe91f1e7 100644 --- a/vendor/github.com/klauspost/reedsolomon/reedsolomon.go +++ b/vendor/github.com/klauspost/reedsolomon/reedsolomon.go @@ -189,7 +189,7 @@ func (r reedSolomon) Verify(shards [][]byte) (bool, error) { // number of matrix rows used, is determined by // outputCount, which is the number of outputs to compute. func (r reedSolomon) codeSomeShards(matrixRows, inputs, outputs [][]byte, outputCount, byteCount int) { - if runtime.GOMAXPROCS(0) > 1 && len(inputs[0]) > splitSize { + if runtime.GOMAXPROCS(0) > 1 && len(inputs[0]) > minSplitSize { r.codeSomeShardsP(matrixRows, inputs, outputs, outputCount, byteCount) return } @@ -205,24 +205,24 @@ func (r reedSolomon) codeSomeShards(matrixRows, inputs, outputs [][]byte, output } } -// How many bytes per goroutine. -const splitSize = 512 +const ( + minSplitSize = 512 // min split size per goroutine + maxGoroutines = 50 // max goroutines number for encoding & decoding +) // Perform the same as codeSomeShards, but split the workload into // several goroutines. func (r reedSolomon) codeSomeShardsP(matrixRows, inputs, outputs [][]byte, outputCount, byteCount int) { var wg sync.WaitGroup - left := byteCount + do := byteCount / maxGoroutines + if do < minSplitSize { + do = minSplitSize + } start := 0 - for { - do := left - if do > splitSize { - do = splitSize + for start < byteCount { + if start+do > byteCount { + do = byteCount - start } - if do == 0 { - break - } - left -= do wg.Add(1) go func(start, stop int) { for c := 0; c < r.DataShards; c++ { @@ -246,22 +246,19 @@ func (r reedSolomon) codeSomeShardsP(matrixRows, inputs, outputs [][]byte, outpu // except this will check values and return // as soon as a difference is found. func (r reedSolomon) checkSomeShards(matrixRows, inputs, toCheck [][]byte, outputCount, byteCount int) bool { - var wg sync.WaitGroup - left := byteCount - start := 0 - same := true var mu sync.RWMutex // For above - for { - do := left - if do > splitSize { - do = splitSize + var wg sync.WaitGroup + do := byteCount / maxGoroutines + if do < minSplitSize { + do = minSplitSize + } + start := 0 + for start < byteCount { + if start+do > byteCount { + do = byteCount - start } - if do == 0 { - break - } - left -= do wg.Add(1) go func(start, do int) { defer wg.Done() @@ -283,7 +280,7 @@ func (r reedSolomon) checkSomeShards(matrixRows, inputs, toCheck [][]byte, outpu } for i, calc := range outputs { - if bytes.Compare(calc, toCheck[i][start:start+do]) != 0 { + if !bytes.Equal(calc, toCheck[i][start:start+do]) { mu.Lock() same = false mu.Unlock() diff --git a/vendor/vendor.json b/vendor/vendor.json index 233161df9..aaabf8f89 100644 --- a/vendor/vendor.json +++ b/vendor/vendor.json @@ -64,8 +64,8 @@ }, { "path": "github.com/klauspost/reedsolomon", - "revision": "d1fe8adc280ef4cd7883943f15a1b5b085a5cced", - "revisionTime": "2016-01-11T14:44:57+01:00" + "revision": "0b630aea2793158b43d0e18f2f50280bfb27c4b4", + "revisionTime": "2016-04-29T14:00:48-07:00" }, { "path": "github.com/mattn/go-colorable",