deltabeard / Peanut-GB

A Game Boy (DMG) emulator single header library written in C99. Performance is prioritised over accuracy.
https://projects.deltabeard.com/peanutgb/
283 stars 40 forks source link

Use `uint_fast#_t` types instead of `unsigned int` #24

Closed deltabeard closed 5 years ago

deltabeard commented 5 years ago

Some systems are faster when they use specific integer types. For variables where the width does not matter, using uint_fast#_t instead since it should provide the most efficient code for the platform.

https://github.com/deltabeard/Peanut-GB/blob/dad797741c5a100bc7e753ef6baf7eb8ca18ddc4/peanut_gb.h#L3021

Additionally, uint32_t could become uint_fast32_t in the following function: https://github.com/deltabeard/Peanut-GB/blob/dad797741c5a100bc7e753ef6baf7eb8ca18ddc4/peanut_gb.h#L3136

A smaller width could be used where small size is preferable over performance, as in: https://github.com/deltabeard/Peanut-GB/blob/dad797741c5a100bc7e753ef6baf7eb8ca18ddc4/peanut_gb.h#L3194

Where the code is executed very infrequently.