From 107b640bc03d30277418da0aa2efcdd4c99e5caf Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 19 Aug 2020 08:58:18 +0200 Subject: [PATCH] Optimize png_read_plte --- libretro-common/formats/png/rpng.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/libretro-common/formats/png/rpng.c b/libretro-common/formats/png/rpng.c index 8837ed761a..e9dd64cc2a 100644 --- a/libretro-common/formats/png/rpng.c +++ b/libretro-common/formats/png/rpng.c @@ -821,14 +821,17 @@ false_end: static bool png_read_plte(uint8_t *buf, uint32_t *buffer, unsigned entries) { - unsigned i; + uint8_t *buf_ptr = NULL; + uint32_t *buffer_ptr = NULL; - for (i = 0; i < entries; i++) + for ( buf_ptr = &buf[0], buffer_ptr = &buffer[0] + ; buffer_ptr < buffer + entries + ; buf_ptr += 3, buffer_ptr++) { - uint32_t r = buf[3 * i + 0]; - uint32_t g = buf[3 * i + 1]; - uint32_t b = buf[3 * i + 2]; - buffer[i] = (r << 16) | (g << 8) | (b << 0) | (0xffu << 24); + uint32_t r = *(buf_ptr); + uint32_t g = *(buf_ptr + 1); + uint32_t b = *(buf_ptr + 2); + *buffer_ptr = (r << 16) | (g << 8) | (b << 0) | (0xffu << 24); } return true;