mirror of
https://bitbucket.org/s_l_teichmann/mtsatellite
synced 2025-01-22 22:30:27 +01:00
Cosmetical: Replaced a map to bools by a map with struct{} values because its more a set.
This commit is contained in:
parent
f437baaac1
commit
3a9fd0ca1e
@ -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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user