Peanut-GB icon indicating copy to clipboard operation
Peanut-GB copied to clipboard

Add likely/unlikely macros for improved performance

Open deltabeard opened this issue 5 years ago • 1 comments

Some checks, like the following NULL check, will either always be true or false depending on if the user application is implemented correctly. When using peanut-gb with LCD enabled, this NULL check should never be true, so it's a bit of a waste. https://github.com/deltabeard/Peanut-GB/blob/dad797741c5a100bc7e753ef6baf7eb8ca18ddc4/peanut_gb.h#L1113

The least we can do is use an unlikely(x) macro here, or we could wrap it in an assert.

Peanut-GB should be profiled, and unlikely/likely macros should be used throughout where there is likely to be significant performance gains.

deltabeard avatar Jun 19 '19 09:06 deltabeard

Removed the milestone because requires a lot of profiling. It would be nice to have a script that plays a few games in order to generate a profile, and then provide suggestions as to where such macros would be most appropriate.

deltabeard avatar Jun 12 '23 10:06 deltabeard