mirror of
https://bitbucket.org/s_l_teichmann/mtsatellite
synced 2024-12-24 01:00:18 +01:00
Use empty structs instead of bools in changes.
This commit is contained in:
parent
da309c73d8
commit
4c24a01607
@ -29,7 +29,7 @@ type baseTilesUpdates interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type tileUpdater struct {
|
type tileUpdater struct {
|
||||||
changes map[xz]bool
|
changes map[xz]struct{}
|
||||||
btu baseTilesUpdates
|
btu baseTilesUpdates
|
||||||
mapDir string
|
mapDir string
|
||||||
redisAddress string
|
redisAddress string
|
||||||
@ -89,7 +89,7 @@ func newTileUpdater(
|
|||||||
mapDir: mapDir,
|
mapDir: mapDir,
|
||||||
redisAddress: redisAddress,
|
redisAddress: redisAddress,
|
||||||
ips: ips,
|
ips: ips,
|
||||||
changes: map[xz]bool{},
|
changes: map[xz]struct{}{},
|
||||||
colors: colors,
|
colors: colors,
|
||||||
bg: bg,
|
bg: bg,
|
||||||
yMin: int16(yMin),
|
yMin: int16(yMin),
|
||||||
@ -146,7 +146,7 @@ func (tu *tileUpdater) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
|
|||||||
if len(newChanges) > 0 {
|
if len(newChanges) > 0 {
|
||||||
tu.cond.L.Lock()
|
tu.cond.L.Lock()
|
||||||
for _, c := range newChanges {
|
for _, c := range newChanges {
|
||||||
tu.changes[c.quantize()] = true
|
tu.changes[c.quantize()] = struct{}{}
|
||||||
}
|
}
|
||||||
tu.cond.L.Unlock()
|
tu.cond.L.Unlock()
|
||||||
tu.cond.Signal()
|
tu.cond.Signal()
|
||||||
@ -155,7 +155,7 @@ func (tu *tileUpdater) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
|
|||||||
rw.WriteHeader(http.StatusOK)
|
rw.WriteHeader(http.StatusOK)
|
||||||
}
|
}
|
||||||
|
|
||||||
func extractChanges(changes map[xz]bool) []xzc {
|
func extractChanges(changes map[xz]struct{}) []xzc {
|
||||||
chs := make([]xzc, len(changes))
|
chs := make([]xzc, len(changes))
|
||||||
var i int
|
var i int
|
||||||
for ch := range changes {
|
for ch := range changes {
|
||||||
@ -185,7 +185,7 @@ func (tu *tileUpdater) doUpdates() {
|
|||||||
tu.cond.Wait()
|
tu.cond.Wait()
|
||||||
}
|
}
|
||||||
changes := extractChanges(tu.changes)
|
changes := extractChanges(tu.changes)
|
||||||
tu.changes = map[xz]bool{}
|
tu.changes = map[xz]struct{}{}
|
||||||
tu.cond.L.Unlock()
|
tu.cond.L.Unlock()
|
||||||
|
|
||||||
baseDir := filepath.Join(tu.mapDir, "8")
|
baseDir := filepath.Join(tu.mapDir, "8")
|
||||||
|
Loading…
Reference in New Issue
Block a user