From 1165632fa0afb1256b4c07d9b71568a07ffeca61 Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Sat, 13 Jul 2013 13:51:47 -0700 Subject: [PATCH] use bytes.Equal() instead, Thanks for Thomas' suggestion --- go/storage/volume.go | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/go/storage/volume.go b/go/storage/volume.go index c2081b2fe..b03e564ca 100644 --- a/go/storage/volume.go +++ b/go/storage/volume.go @@ -1,6 +1,7 @@ package storage import ( + "bytes" "errors" "fmt" "io" @@ -166,13 +167,7 @@ func (v *Volume) isFileUnchanged(n *Needle) bool { } oldNeedle := new(Needle) oldNeedle.Read(v.dataFile, nv.Size, v.Version()) - if len(oldNeedle.Data) == len(n.Data) && oldNeedle.Checksum == n.Checksum { - length := len(n.Data) - for i := 0; i < length; i++ { - if n.Data[i] != oldNeedle.Data[i] { - return false - } - } + if oldNeedle.Checksum == n.Checksum && bytes.Equal(oldNeedle.Data, n.Data) { n.Size = oldNeedle.Size return true }