emilk / egui

egui: an easy-to-use immediate mode GUI in Rust that runs on both web and native
https://www.egui.rs/
Apache License 2.0
22.37k stars 1.61k forks source link

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

Open emilk opened 9 months ago

emilk commented 9 months ago

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.

YgorSouza commented 9 months ago

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.

BSFishy commented 9 months ago

I would love to take this on!

emilk commented 9 months ago

I think adding a dependency on bitflags is fine

RonnieJr21 commented 9 months ago

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!

toastxc commented 7 months ago

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

toastxc commented 7 months ago

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

toastxc commented 7 months ago

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

toastxc commented 7 months ago

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