From ff651a7941752c275c1940f3e729f8183a46fe18 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Thu, 4 Apr 2024 10:40:36 -0400 Subject: [PATCH] filesystem: Turn off case-insensitivity if glob pattern is NULL. Just a small optimization; it'll avoid some allocations and case-folding we don't actually need the results of later. --- src/filesystem/SDL_filesystem.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/filesystem/SDL_filesystem.c b/src/filesystem/SDL_filesystem.c index 2c67999c65..65be3e0f4e 100644 --- a/src/filesystem/SDL_filesystem.c +++ b/src/filesystem/SDL_filesystem.c @@ -270,8 +270,13 @@ char **SDL_InternalGlobDirectory(const char *path, const char *pattern, Uint32 f path = pathcpy; } + if (!pattern) { + flags &= ~SDL_GLOB_CASEINSENSITIVE; // avoid some unnecessary allocations and work later. + } + char *folded = NULL; - if (pattern && (flags & SDL_GLOB_CASEINSENSITIVE)) { + if (flags & SDL_GLOB_CASEINSENSITIVE) { + SDL_assert(pattern != NULL); folded = CaseFoldUtf8String(pattern); if (!folded) { SDL_free(pathcpy);