Merge pull request #715 from abperiasamy/intMax

replace intMax with math.Max
This commit is contained in:
Anand Babu (AB) Periasamy
2015-05-30 12:25:05 -07:00
4 changed files with 6 additions and 11 deletions
-8
View File
@@ -22,14 +22,6 @@ import (
"github.com/minio/minio/pkg/iodine"
)
// intMax - return maximum value for any given integer
func intMax(x, y int) int {
if x > y {
return x
}
return y
}
// isValidRetry - check if we should retry for the given error sequence
func isValidRetry(err error) bool {
err = iodine.New(err, nil)
+2 -1
View File
@@ -20,6 +20,7 @@ import (
"errors"
"fmt"
"io"
"math"
"runtime"
"sync"
@@ -120,7 +121,7 @@ func doCopyCmd(sourceURLs []string, targetURL string, bar barSend) <-chan error
}(sourceURLs, targetURL)
// Pool limited copy routines in parallel.
cpQueue := make(chan bool, intMax(runtime.NumCPU()-1, 1))
cpQueue := make(chan bool, int(math.Max(float64(runtime.NumCPU())-1, 1)))
defer close(cpQueue)
// Wait for all copy routines to complete.
+2 -1
View File
@@ -19,6 +19,7 @@ package main
import (
"errors"
"fmt"
"math"
"runtime"
"sync"
@@ -71,7 +72,7 @@ func runSyncCmd(ctx *cli.Context) {
}
}(sourceURL, targetURLs)
var syncQueue = make(chan bool, intMax(runtime.NumCPU()-1, 1))
syncQueue := make(chan bool, int(math.Max(float64(runtime.NumCPU())-1, 1)))
var wg sync.WaitGroup
for syncURLs := range prepareSyncURLs(sourceURL, targetURLs) {
+2 -1
View File
@@ -18,6 +18,7 @@ package main
import (
"fmt"
"math"
"runtime"
"strings"
@@ -47,7 +48,7 @@ func printUpdateNotify(latestVersion, currentVersion string) {
line2InColor := fmt.Sprintf(" Run \"%s\" to update. ", blue(updateString))
// calculate the rectangular box size
maxContentWidth := intMax(line1Length, line2Length)
maxContentWidth := int(math.Max(float64(line1Length), float64(line2Length)))
line1Rest := maxContentWidth - line1Length
line2Rest := maxContentWidth - line2Length