~eliasnaur/gio-patches

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch
3 3

[PATCH gio] io/router: avoid unnecessary event copies in deliverEvent

~pierrec
Details
Message ID
<161410023476.27320.10907205475870932419-0@git.sr.ht>
DKIM signature
missing
Download raw message
Patch: +14 -8
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(-)

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
		}

		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] build success

builds.sr.ht
Details
Message ID
<C9H3DJ73LFMK.1T7MJ1Q6G3GNF@cirno2>
In-Reply-To
<161410023476.27320.10907205475870932419-0@git.sr.ht> (view parent)
DKIM signature
missing
Download raw message
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
Details
Message ID
<C9HNDCMYL03Z.11X0YXCF58P8P@themachine>
In-Reply-To
<161410023476.27320.10907205475870932419-0@git.sr.ht> (view parent)
DKIM signature
fail
Download raw message
DKIM signature: fail
On Tue Feb 23, 2021 at 18:09, ~pierrec wrote:
> 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
Details
Message ID
<CAG3idSeh9yGBJvmX5Kd5KWkWZeK7YUpuFLYTLKRG-75_iFvMLQ@mail.gmail.com>
In-Reply-To
<C9HNDCMYL03Z.11X0YXCF58P8P@themachine> (view parent)
DKIM signature
pass
Download raw message
Le mer. 24 févr. 2021 à 10:18, Elias Naur <mail@eliasnaur.com> a écrit :
>
> On Tue Feb 23, 2021 at 18:09, ~pierrec wrote:
> > 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?

I guess this is purely style.

>
> > 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.

Patch incoming.

>
> >               }
> > -
> > -             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
>
Reply to thread Export thread (mbox)