svenstaro / rofi-calc

🖩 Do live calculations in rofi!
MIT License
964 stars 31 forks source link

intense use of CPU #96

Closed carmelopellegrino closed 1 year ago

carmelopellegrino commented 1 year ago

Hi,

I've noticed that rofi-calc uses a lot of CPU when there is no user input after a first evaluation has been performed. I think the problem is that it repeatedly calls the calc_preprocess_input function, even if there is no new input.

This behaviour has been tested only on Arch Linux, I don't know of other affected distros.

As a solution for this behaviour, I've forked the project and made this commit, although I don't really know if it's the best solution. For example, I tried using the sw->cmd field with similar results, but I'm not sure of any possible corner case that could break the code somewhere else.

I can start a pull request, if desired.

svenstaro commented 1 year ago

I think that's a fine idea. I also just now noticed this behavior. I like your general solution, just make sure to remove the debug and slap some comments onto it so we know what it's for without reading the code.

svenstaro commented 1 year ago

Nevermind, looks like this is actually solved in #66. I just haven't given this project love in some time. I'll merge that instead.

svenstaro commented 1 year ago

I merged it, please see whether it works for you. I'll then cut a release.

svenstaro commented 1 year ago

Actually there was a memory leak in #66 and the fixed version looks a lot like yours. :D

carmelopellegrino commented 1 year ago

Hi @svenstaro, sorry for having disappeared! Thank you for the fix!