From 69562deb23086723ddd729fa622e761f0bad6974 Mon Sep 17 00:00:00 2001 From: "Anand Babu (AB) Periasamy" Date: Sat, 30 May 2015 12:16:58 -0700 Subject: [PATCH] replace intMax with math.Max --- cmd-common.go | 8 -------- cmd-cp.go | 3 ++- cmd-sync.go | 3 ++- notifier.go | 3 ++- 4 files changed, 6 insertions(+), 11 deletions(-) diff --git a/cmd-common.go b/cmd-common.go index 7b38c35d..2fe8fd26 100644 --- a/cmd-common.go +++ b/cmd-common.go @@ -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) diff --git a/cmd-cp.go b/cmd-cp.go index 3e6dd8aa..c9bafaac 100644 --- a/cmd-cp.go +++ b/cmd-cp.go @@ -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. diff --git a/cmd-sync.go b/cmd-sync.go index 6f75647f..4676741d 100644 --- a/cmd-sync.go +++ b/cmd-sync.go @@ -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) { diff --git a/notifier.go b/notifier.go index 50d93f96..62a1fb01 100644 --- a/notifier.go +++ b/notifier.go @@ -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