From f4a00c9904c1091a19cb547664798dafcf43d6ae Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Wed, 28 Oct 2015 13:47:45 -0700 Subject: [PATCH] Remove usage of strings.Compare - always golangs native checks like ">, <, ==" for strings --- diff.go | 8 +++----- sorted-list.go | 6 ++---- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/diff.go b/diff.go index 8fe5e640..7dffa503 100644 --- a/diff.go +++ b/diff.go @@ -272,9 +272,7 @@ func dodiffRecursive(firstClnt, secondClnt client.Client, ch chan DiffMessage) { } fC := f.Content sC := s.Content - compare := strings.Compare(fC.Name, sC.Name) - - if compare == 0 { + if fC.Name == sC.Name { if fC.Type.IsRegular() { if !sC.Type.IsRegular() { ch <- DiffMessage{ @@ -301,7 +299,7 @@ func dodiffRecursive(firstClnt, secondClnt client.Client, ch chan DiffMessage) { f, fok = <-fch s, sok = <-sch } - if compare < 0 { + if fC.Name < sC.Name { ch <- DiffMessage{ FirstURL: firstURL, SecondURL: secondURL, @@ -309,7 +307,7 @@ func dodiffRecursive(firstClnt, secondClnt client.Client, ch chan DiffMessage) { } f, fok = <-fch } - if compare > 0 { + if fC.Name > sC.Name { s, sok = <-sch } } diff --git a/sorted-list.go b/sorted-list.go index 38af1121..8266b041 100644 --- a/sorted-list.go +++ b/sorted-list.go @@ -22,7 +22,6 @@ import ( "io" "os" "path/filepath" - "strings" "github.com/minio/mc/pkg/client" "github.com/minio/minio-xl/pkg/probe" @@ -143,14 +142,13 @@ func (sl *sortedList) Match(source *client.Content) (bool, *probe.Error) { } } for { - compare := strings.Compare(source.Name, sl.current.Name) - if compare == 0 { + if source.Name == sl.current.Name { if source.Type.IsRegular() && sl.current.Type.IsRegular() && source.Size == sl.current.Size { return true, nil } return false, nil } - if compare < 0 { + if source.Name < sl.current.Name { return false, nil } // assign zero values to fields because if s.current's previous decode had non zero value