app/internal/window: [macOS] use regular map for view-to-window lookups

All accesses to the view map now happens on the main thread, so
there is no need for a sync.Map anymore.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2020-06-03 19:47:38 +02:00
parent 1a070a36b6
commit c225daa845
+5 -6
View File
@@ -8,7 +8,6 @@ import (
"errors"
"image"
"runtime"
"sync"
"time"
"unicode"
"unicode/utf16"
@@ -57,7 +56,7 @@ type window struct {
}
// viewMap is the mapping from Cocoa NSViews to Go windows.
var viewMap sync.Map
var viewMap = make(map[C.CFTypeRef]*window)
var mainWindow = newWindowRendezvous()
@@ -74,19 +73,19 @@ func mustView(view C.CFTypeRef) *window {
}
func lookupView(view C.CFTypeRef) (*window, bool) {
w, exists := viewMap.Load(view)
w, exists := viewMap[view]
if !exists {
return nil, false
}
return w.(*window), true
return w, true
}
func deleteView(view C.CFTypeRef) {
viewMap.Delete(view)
delete(viewMap, view)
}
func insertView(view C.CFTypeRef, w *window) {
viewMap.Store(view, w)
viewMap[view] = w
}
func (w *window) contextView() C.CFTypeRef {