plutov / ultrafocus

CLI tool to block distracting websites and boost productivity.
MIT License
136 stars 8 forks source link

refactor: optimise structs to reduce memory usage and add gmail host #6

Closed rflpazini closed 3 months ago

plutov commented 3 months ago

Can you explain please the memory usage improvements? I think gmail.com is a valid domain when you want to focus on work.

rflpazini commented 3 months ago

Sure! Regarding the memory usage improvements, you might already know that the order of fields in a struct directly affects the memory usage of our application. If you want to read more about this, here is an article that explains it better than I can. 😅

To optimize memory allocation, I reordered some structs in the code.

Here are the results from the reordered fields:

Screenshot 2024-07-29 at 23 58 25

I used the fieldalignment tool to apply these changes to the code.

Also I agree with you about the gmail.com domain. But when I'm on ultra focus I don't want to answer emails haha. But I got your point @plutov!

BTW, thanks for letting me contribute with your project and have this chat with you ❤️

plutov commented 3 months ago

Got it, makes sense. You can still add gmail.com in your own config, so maybe let's not put it into the default list just yet.