From 2b2df194dc7f389309a4b56dfdc676e0cdac8951 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustaf=20Alh=C3=A4ll?= Date: Sun, 8 Dec 2024 16:13:45 +0100 Subject: [PATCH 1/2] Fix performance regressions in addon loading --- src/w_wad.c | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/src/w_wad.c b/src/w_wad.c index 57dd09de6..50ba622a9 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -1358,17 +1358,6 @@ UINT16 W_CheckNumForFolderEndPK3(const char *name, UINT16 wad, UINT16 startlump) return i; } -// Returns 0 if the folder is not empty, 1 if it is empty, -1 if it doesn't exist -INT32 W_IsFolderEmpty(const char *name, UINT16 wad) -{ - UINT16 start = W_CheckNumForFolderStartPK3(name, wad, 0); - if (start == INT16_MAX) - return -1; - - // Unlike W_CheckNumForFolderStartPK3, W_CheckNumForFolderEndPK3 doesn't return INT16_MAX. - return W_CheckNumForFolderEndPK3(name, wad, start) <= start; -} - char *W_GetLumpFolderPathPK3(UINT16 wad, UINT16 lump) { const char *fullname = wadfiles[wad]->lumpinfo[lump].fullname; @@ -1733,10 +1722,14 @@ static UINT16 W_CheckNumForPatchNamePwad(const char *name, UINT16 wad, boolean l // TODO: cache namespace lump IDs if (W_FileHasFolders(wadfiles[wad])) { - if (!W_IsFolderEmpty("Flats/", wad)) + start = W_CheckNumForFolderStartPK3("Flats/", wad, 0); + end = W_CheckNumForFolderEndPK3("Flats/", wad, start); + + // if the start and end is the same, the folder is empty + if (end <= start) { - start = W_CheckNumForFolderStartPK3("Flats/", wad, 0); - end = W_CheckNumForFolderEndPK3("Flats/", wad, start); + start = INT16_MAX; + end = INT16_MAX; } } else From bf23d61dc17bc4c97e29644fd9152fc8aba22e8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustaf=20Alh=C3=A4ll?= Date: Sun, 8 Dec 2024 20:32:04 +0100 Subject: [PATCH 2/2] Remove W_IsFolderEmpty header definition --- src/w_wad.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/w_wad.h b/src/w_wad.h index 5872ae50a..84aafa3a4 100644 --- a/src/w_wad.h +++ b/src/w_wad.h @@ -180,7 +180,6 @@ UINT16 W_CheckNumForMarkerStartPwad(const char *name, UINT16 wad, UINT16 startlu UINT16 W_CheckNumForFullNamePK3(const char *name, UINT16 wad, UINT16 startlump); UINT16 W_CheckNumForFolderStartPK3(const char *name, UINT16 wad, UINT16 startlump); UINT16 W_CheckNumForFolderEndPK3(const char *name, UINT16 wad, UINT16 startlump); -INT32 W_IsFolderEmpty(const char *name, UINT16 wad); char *W_GetLumpFolderPathPK3(UINT16 wad, UINT16 lump); char *W_GetLumpFolderNamePK3(UINT16 wad, UINT16 lump);