From c44640e6877a4b12b8607cb9bde7effc5d19bf86 Mon Sep 17 00:00:00 2001 From: dinkc64 <12570148+dinkc64@users.noreply.github.com> Date: Tue, 28 Mar 2017 01:00:11 +0000 Subject: [PATCH] burner/sel.cpp: slight speedup to search function [tumu] --- src/burner/win32/sel.cpp | 52 +++++++++++++++++++--------------------- 1 file changed, 25 insertions(+), 27 deletions(-) diff --git a/src/burner/win32/sel.cpp b/src/burner/win32/sel.cpp index de8e22316..c854126eb 100644 --- a/src/burner/win32/sel.cpp +++ b/src/burner/win32/sel.cpp @@ -501,8 +501,13 @@ static int SelListMake() LoadFavorites(); - // Add all the driver names to the list + // Get dialog search string + TCHAR szSearchString[256] = { _T("") }; + j = GetDlgItemText(hSelDlg, IDC_SEL_SEARCH, szSearchString, sizeof(szSearchString)); + for (UINT32 k = 0; k < j; k++) + szSearchString[k] = _totlower(szSearchString[k]); + // Add all the driver names to the list // 1st: parents for (i = 0; i < nBurnDrvCount; i++) { TV_INSERTSTRUCT TvItem; @@ -523,11 +528,17 @@ static int SelListMake() if ((nHardware & MASKALL) && ((nHardware & nLoadMenuShowX) || (nHardware & MASKALL) == 0)) { continue; } + + if (avOk && (!(nLoadMenuShowY & UNAVAILABLE)) && !gameAv[i]) { // Skip non-available games if needed + continue; + } + + if (avOk && (!(nLoadMenuShowY & AVAILABLE)) && gameAv[i]) { // Skip available games if needed + continue; + } if (DoExtraFilters()) continue; - TCHAR szSearchString[256]; - GetDlgItemText(hSelDlg, IDC_SEL_SEARCH, szSearchString, sizeof(szSearchString)); if (szSearchString[0]) { TCHAR *StringFound = NULL; TCHAR *StringFound2 = NULL; @@ -539,8 +550,7 @@ static int SelListMake() wcscpy(szDriverName, BurnDrvGetText(DRV_FULLNAME)); wcscpy(szManufacturerName, BurnDrvGetText(DRV_MANUFACTURER)); wcscpy(szSystemName, BurnDrvGetText(DRV_SYSTEM)); - for (int k =0; k < 256; k++) { - szSearchString[k] = _totlower(szSearchString[k]); + for (int k = 0; k < 256; k++) { szDriverName[k] = _totlower(szDriverName[k]); szManufacturerName[k] = _totlower(szManufacturerName[k]); szSystemName[k] = _totlower(szSystemName[k]); @@ -553,14 +563,6 @@ static int SelListMake() if (!StringFound && !StringFound2 && !StringFound3 && !StringFound4) continue; } - if (avOk && (!(nLoadMenuShowY & UNAVAILABLE)) && !gameAv[i]) { // Skip non-available games if needed - continue; - } - - if (avOk && (!(nLoadMenuShowY & AVAILABLE)) && gameAv[i]) { // Skip available games if needed - continue; - } - memset(&TvItem, 0, sizeof(TvItem)); TvItem.item.mask = TVIF_TEXT | TVIF_PARAM; TvItem.hInsertAfter = TVI_SORT; @@ -593,24 +595,29 @@ static int SelListMake() if ((nHardware & MASKALL) && ((nHardware & nLoadMenuShowX) || ((nHardware & MASKALL) == 0))) { continue; } + + if (avOk && (!(nLoadMenuShowY & UNAVAILABLE)) && !gameAv[i]) { // Skip non-available games if needed + continue; + } + + if (avOk && (!(nLoadMenuShowY & AVAILABLE)) && gameAv[i]) { // Skip available games if needed + continue; + } if (DoExtraFilters()) continue; - TCHAR szSearchString[256]; - GetDlgItemText(hSelDlg, IDC_SEL_SEARCH, szSearchString, sizeof(szSearchString)); if (szSearchString[0]) { TCHAR *StringFound = NULL; TCHAR *StringFound2 = NULL; TCHAR *StringFound3 = NULL; TCHAR *StringFound4 = NULL; - TCHAR szDriverName[256]; + TCHAR szDriverName[256] = { _T("") }; TCHAR szManufacturerName[256] = { _T("") }; TCHAR szSystemName[256] = { _T("") }; wcscpy(szDriverName, BurnDrvGetText(DRV_FULLNAME)); wcscpy(szManufacturerName, BurnDrvGetText(DRV_MANUFACTURER)); wcscpy(szSystemName, BurnDrvGetText(DRV_SYSTEM)); for (int k =0; k < 256; k++) { - szSearchString[k] = _totlower(szSearchString[k]); szDriverName[k] = _totlower(szDriverName[k]); szManufacturerName[k] = _totlower(szManufacturerName[k]); szSystemName[k] = _totlower(szSystemName[k]); @@ -623,14 +630,6 @@ static int SelListMake() if (!StringFound && !StringFound2 && !StringFound3 && !StringFound4) continue; } - if (avOk && (!(nLoadMenuShowY & UNAVAILABLE)) && !gameAv[i]) { // Skip non-available games if needed - continue; - } - - if (avOk && (!(nLoadMenuShowY & AVAILABLE)) && gameAv[i]) { // Skip available games if needed - continue; - } - memset(&TvItem, 0, sizeof(TvItem)); TvItem.item.mask = TVIF_TEXT | TVIF_PARAM; TvItem.hInsertAfter = TVI_SORT; @@ -681,7 +680,6 @@ static int SelListMake() } for (i = 0; i < nTmpDrvCount; i++) { - // See if we need to expand the branch of an unavailable or non-working parent if (nBurnDrv[i].bIsParent && ((nLoadMenuShowY & AUTOEXPAND) || !gameAv[nBurnDrv[i].nBurnDrvNo] || !CheckWorkingStatus(nBurnDrv[i].nBurnDrvNo))) { for (j = 0; j < nTmpDrvCount; j++) { @@ -691,7 +689,7 @@ static int SelListMake() nBurnDrvActive = nBurnDrv[j].nBurnDrvNo; if (BurnDrvGetTextA(DRV_PARENT)) { if (strcmp(nBurnDrv[i].pszROMName, BurnDrvGetTextA(DRV_PARENT)) == 0) { - SendMessage(hSelList, TVM_EXPAND,TVE_EXPAND, (LPARAM)nBurnDrv[i].hTreeHandle); + SendMessage(hSelList, TVM_EXPAND, TVE_EXPAND, (LPARAM)nBurnDrv[i].hTreeHandle); break; } }