diff --git a/cmd/mtwebmapper/forwardupdates.go b/cmd/mtwebmapper/forwardupdates.go index c2b0dea..d492d9d 100644 --- a/cmd/mtwebmapper/forwardupdates.go +++ b/cmd/mtwebmapper/forwardupdates.go @@ -27,7 +27,7 @@ type connection struct { } type msg struct { - tiles map[xz]bool + tiles []xz pls []*player } @@ -57,12 +57,8 @@ func (wsf *websocketForwarder) run() { } encMsg := map[string]interface{}{} - if tiles := message.tiles; tiles != nil { - xzs := make([]xz, 0, len(tiles)) - for xz := range tiles { - xzs = append(xzs, xz) - } - encMsg["tiles"] = xzs + if message.tiles != nil { + encMsg["tiles"] = message.tiles } if message.pls != nil { @@ -101,7 +97,7 @@ func (wsf *websocketForwarder) ServeHTTP(rw http.ResponseWriter, r *http.Request c.reader() } -func (wsf *websocketForwarder) BaseTilesUpdated(changes map[xz]bool) { +func (wsf *websocketForwarder) BaseTilesUpdated(changes []xz) { wsf.broadcast <- msg{tiles: changes} } diff --git a/cmd/mtwebmapper/tilesupdater.go b/cmd/mtwebmapper/tilesupdater.go index 4d360e0..8b09a0e 100644 --- a/cmd/mtwebmapper/tilesupdater.go +++ b/cmd/mtwebmapper/tilesupdater.go @@ -25,7 +25,7 @@ import ( ) type baseTilesUpdates interface { - BaseTilesUpdated(map[xz]bool) + BaseTilesUpdated([]xz) } type tileUpdater struct { @@ -165,11 +165,11 @@ func extractChanges(changes map[xz]bool) []xzc { return chs } -func activeChanges(changes []xzc) map[xz]bool { - chs := make(map[xz]bool) +func activeChanges(changes []xzc) []xz { + chs := make([]xz, 0, len(changes)) for i := range changes { if !changes[i].canceled { - chs[changes[i].xz] = true + chs = append(chs, changes[i].xz) } } return chs @@ -222,8 +222,8 @@ func (tu *tileUpdater) doUpdates() { } parentJobs := make(map[xz]uint16) - for c := range actChs { - pxz := c.parent() + for i := range actChs { + pxz := actChs[i].parent() parentJobs[pxz.P] |= pxz.Mask }