From 3a9fd0ca1ec531217fede2bfa3e79b5afa78aa53 Mon Sep 17 00:00:00 2001 From: "Sascha L. Teichmann" Date: Mon, 27 Feb 2017 16:12:19 +0100 Subject: [PATCH] Cosmetical: Replaced a map to bools by a map with struct{} values because its more a set. --- cmd/mtredisalize/changetracker.go | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/cmd/mtredisalize/changetracker.go b/cmd/mtredisalize/changetracker.go index 331b46f..04ae678 100644 --- a/cmd/mtredisalize/changetracker.go +++ b/cmd/mtredisalize/changetracker.go @@ -23,28 +23,28 @@ type quantizedXZ struct { } type changeTracker struct { - changes map[quantizedXZ]bool + changes map[quantizedXZ]struct{} mutex sync.Mutex } func newChangeTracker() *changeTracker { - return &changeTracker{changes: make(map[quantizedXZ]bool)} + return &changeTracker{changes: make(map[quantizedXZ]struct{})} } func (ct *changeTracker) BlockChanged(coord common.Coord) { ct.mutex.Lock() ct.changes[quantizedXZ{ X: coord.X / quantizationFactor, - Z: coord.Z / quantizationFactor}] = true + Z: coord.Z / quantizationFactor}] = struct{}{} ct.mutex.Unlock() } func (ct *changeTracker) FlushChanges(url string) { - var oldChanges map[quantizedXZ]bool + var oldChanges map[quantizedXZ]struct{} ct.mutex.Lock() if len(ct.changes) > 0 { oldChanges = ct.changes - ct.changes = make(map[quantizedXZ]bool) + ct.changes = make(map[quantizedXZ]struct{}) } ct.mutex.Unlock() if oldChanges == nil { @@ -74,5 +74,4 @@ func (ct *changeTracker) FlushChanges(url string) { log.Printf("WARN: posting changes to %s failed: %s\n", url, err) } }() - return }