[PATCH gio] io/router: avoid unnecessary event copies in deliverEvent
Export this patch
From: pierre <pierre.curto@gmail.com>
Signed-off-by: pierre <pierre.curto@gmail.com>
---
io/router/pointer.go | 22 ++++++++++++++--------
1 file changed, 14 insertions(+), 8 deletions(-)
This is net +6 lines change. Is it worth it?
diff --git a/io/router/pointer.go b/io/router/pointer.go
index ab9348b..cd316dd 100644
--- a/io/router/pointer.go
+++ b/io/router/pointer.go
@@ -331,20 +331,26 @@ func (q *pointerQueue) Push(e pointer.Event, events *handlerEvents) {
func (q *pointerQueue) deliverEvent(p *pointerInfo, events *handlerEvents, e pointer.Event) {
foremost := true
+ pressedSingle := p.pressed && len(p.handlers) == 1
+ pos := e.Position
for _, k := range p.handlers {
h := q.handlers[k]
- e := e
- if p.pressed && len(p.handlers) == 1 {
- e.Priority = pointer.Grabbed
- } else if foremost {
- e.Priority = pointer.Foremost
+ if e.Type&h.types == 0 {
+ continue
Early continue is good, though, and avoids copies for filtered events.
}
-
- if e.Type&h.types != 0 {
- e.Position = q.invTransform(h.area, e.Position)
+ e.Position = q.invTransform(h.area, pos)
+ switch {
+ case pressedSingle:
+ e.Priority = pointer.Grabbed
+ case foremost:
foremost = false
+ priority := e.Priority
+ e.Priority = pointer.Foremost
events.Add(k, e)
+ e.Priority = priority
+ continue
}
+ events.Add(k, e)
}
}
--
2.30.1
gio/patches: SUCCESS in 27m57s
[io/router: avoid unnecessary event copies in deliverEvent][0] from [~pierrec][1]
[0]: https://lists.sr.ht/~eliasnaur/gio-patches/patches/20474
[1]: mailto:pierre.curto@gmail.com
✓ #436361 SUCCESS gio/patches/linux.yml https://builds.sr.ht/~eliasnaur/job/436361
✓ #436359 SUCCESS gio/patches/apple.yml https://builds.sr.ht/~eliasnaur/job/436359
✓ #436360 SUCCESS gio/patches/freebsd.yml https://builds.sr.ht/~eliasnaur/job/436360
✓ #436362 SUCCESS gio/patches/openbsd.yml https://builds.sr.ht/~eliasnaur/job/436362