Use empty structs instead of bools in changes.

This commit is contained in:
Sascha L. Teichmann 2016-05-08 23:20:51 +02:00
parent da309c73d8
commit 4c24a01607

View File

@ -29,7 +29,7 @@ type baseTilesUpdates interface {
}
type tileUpdater struct {
changes map[xz]bool
changes map[xz]struct{}
btu baseTilesUpdates
mapDir string
redisAddress string
@ -89,7 +89,7 @@ func newTileUpdater(
mapDir: mapDir,
redisAddress: redisAddress,
ips: ips,
changes: map[xz]bool{},
changes: map[xz]struct{}{},
colors: colors,
bg: bg,
yMin: int16(yMin),
@ -146,7 +146,7 @@ func (tu *tileUpdater) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
if len(newChanges) > 0 {
tu.cond.L.Lock()
for _, c := range newChanges {
tu.changes[c.quantize()] = true
tu.changes[c.quantize()] = struct{}{}
}
tu.cond.L.Unlock()
tu.cond.Signal()
@ -155,7 +155,7 @@ func (tu *tileUpdater) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
rw.WriteHeader(http.StatusOK)
}
func extractChanges(changes map[xz]bool) []xzc {
func extractChanges(changes map[xz]struct{}) []xzc {
chs := make([]xzc, len(changes))
var i int
for ch := range changes {
@ -185,7 +185,7 @@ func (tu *tileUpdater) doUpdates() {
tu.cond.Wait()
}
changes := extractChanges(tu.changes)
tu.changes = map[xz]bool{}
tu.changes = map[xz]struct{}{}
tu.cond.L.Unlock()
baseDir := filepath.Join(tu.mapDir, "8")