diff --git a/common/basetilehash.go b/common/basetilehash.go index 506c464..19e0146 100644 --- a/common/basetilehash.go +++ b/common/basetilehash.go @@ -10,32 +10,27 @@ import ( "sync" ) -type btPos struct { - x int - y int -} - type BaseTileHash struct { // XXX: Maybe use some kind of LRU cache instead? - hashes map[btPos][]byte + hashes map[struct{ x, y int }][]byte sync.Mutex } func NewBaseTileHash() *BaseTileHash { - return &BaseTileHash{hashes: map[btPos][]byte{}} + return &BaseTileHash{hashes: map[struct{ x, y int }][]byte{}} } func (bth *BaseTileHash) Update(x, y int, img image.Image) bool { hash := SHA1Image(img) - key := btPos{x, y} + key := struct{ x, y int }{x, y} bth.Lock() defer bth.Unlock() if old, found := bth.hashes[key]; found { - equals := bytes.Equal(old, hash) - if !equals { + if !bytes.Equal(old, hash) { bth.hashes[key] = hash + return true } - return !equals + return false } bth.hashes[key] = hash return true