From 6cf6c4be25e45b685b9bb3b1ea76c8ac1badeefa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dani=C3=ABl=20Heres?= Date: Tue, 20 Oct 2015 18:06:03 +0200 Subject: [PATCH 1/2] Optimize bitscanforward using intrinsic function --- src/util/util.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/util/util.c b/src/util/util.c index f17ac3f424..d7f081357b 100644 --- a/src/util/util.c +++ b/src/util/util.c @@ -143,11 +143,16 @@ int bitscanforward(int source) { int i; + #if _MSC_VER >= 1400 // Visual Studio 2005 + _BitScanForward(&i, source); + return i; + #else for (i = 0; i < 32; i++) if (source & (1 << i)) return i; return -1; + #endif } int bitcount(int source) From 17b906b3a0c07e71c3c3fbf010e8f7215ec4233c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dani=C3=ABl=20Heres?= Date: Wed, 21 Oct 2015 09:10:43 +0200 Subject: [PATCH 2/2] Use SDL_RWsize to get size info --- src/util/util.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/util/util.c b/src/util/util.c index 2189de7e91..467172aed7 100644 --- a/src/util/util.c +++ b/src/util/util.c @@ -125,9 +125,7 @@ bool readentirefile(const utf8 *path, void **outBuffer, int *outLength) return 0; // Get length - SDL_RWseek(fp, 0, RW_SEEK_END); - fpLength = (int)SDL_RWtell(fp); - SDL_RWseek(fp, 0, RW_SEEK_SET); + fpLength = (int)SDL_RWsize(fp); // Read whole file into a buffer fpBuffer = malloc(fpLength);