mirror of
				https://bitbucket.org/s_l_teichmann/mtsatellite
				synced 2025-11-04 09:55:34 +01:00 
			
		
		
		
	Cosmetical: Replaced a map to bools by a map with struct{} values because its more a set.
This commit is contained in:
		@@ -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
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user