# HG changeset patch # User Mike Becker # Date 1751056217 -7200 # Node ID 3d6d50a852a9955431ef11217ea2a9a095c0b71a # Parent 6e6717d9c77642f9916aec04f8987ec46f1ee3d1 optimize asc_col_itof() diff -r 6e6717d9c776 -r 3d6d50a852a9 src/ascension/datatypes.h --- a/src/ascension/datatypes.h Thu Jun 26 21:43:22 2025 +0200 +++ b/src/ascension/datatypes.h Fri Jun 27 22:30:17 2025 +0200 @@ -164,13 +164,13 @@ static inline asc_col4f asc_col_itof(asc_col4i c) { // dividing by 256 is much more performant - // TODO: this loses optimized rendering for zero-color / alpha - return (asc_col4f) { - (c.red+1.f) / 256.f, - (c.green+1.f) / 256.f, - (c.blue+1.f) / 256.f, - (c.alpha+1.f) / 256.f, - }; + // because it compiles to multiplication instead of division + const float f = 256.f / 255.f; + const float red = c.red * f / 256.f; + const float green = c.green * f / 256.f; + const float blue = c.blue * f / 256.f; + const float alpha = c.alpha * f / 256.f; + return (asc_col4f) {red, green, blue, alpha}; } static inline SDL_Color asc_col_sdl(asc_col4i col) {