فهرست منبع

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.
Ryan C. Gordon 1 سال پیش
والد
کامیت
ff651a7941
1فایلهای تغییر یافته به همراه6 افزوده شده و 1 حذف شده
  1. 6 1
      src/filesystem/SDL_filesystem.c

+ 6 - 1
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);