egui icon indicating copy to clipboard operation
egui copied to clipboard

Performance: replace bools in `Response` with bit-sets

Open emilk opened this issue 1 year ago • 3 comments
trafficstars

Response is 88 bytes large. Around 26 bytes of that is because of as many bools, which could be combines into a few bit-sets instead of 4 bytes.

This also includes Sense which has the same problem.

We also have several; [bool; NUM_POINTER_BUTTONS] which could be replaced with a bit-set each (PointerButtons or something).

Ideally we could solve this in an ergonomic way without any additional additional dependencies.

emilk avatar Jan 22 '24 13:01 emilk

Is adding bitflags such a big deal? It's a pretty small dependency, and most egui projects probably already depend on it anyway (it appears 39 times in this repo's lock file). It would save a lot of boilerplate.

YgorSouza avatar Jan 22 '24 21:01 YgorSouza

I would love to take this on!

BSFishy avatar Jan 23 '24 03:01 BSFishy

I think adding a dependency on bitflags is fine

emilk avatar Jan 23 '24 14:01 emilk

Hey im pretty new but I have been trying to learn rust from docs and videos, I wanted to see if I could help with this project and saw this was a good first issue. I would love to help as much as possible but I still have a lot to learn!

RonnieJr21 avatar Jan 28 '24 02:01 RonnieJr21

Heya, I've started work on this since it seems like fun. I'm about halfway through Response. edit: Response is done

toastxc avatar Mar 26 '24 03:03 toastxc

I've managed to get it working without any extra dependencies! just math.

toastxc avatar Mar 27 '24 12:03 toastxc

Question: Sense literally just contains bools, should be be a struct containing u64? pub struct Sense (u64);

toastxc avatar Mar 27 '24 12:03 toastxc

The initial implementation is complete, all tests have passed. https://github.com/toastxc/egui

toastxc avatar Mar 27 '24 15:03 toastxc