This is called a huge number of time every time the module is loaded. The function does a lot of things, which I believe aren't necessary for uxtheme string comparison. The impact on process startup is noticeable, and this saves ~1min on the Gitlab CI test run.
Instead, convert strings to uppercase beforehand in a locale-independent way, and compare with wcscmp.
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/uxtheme/msstyles.c | 6 ++++++ dlls/uxtheme/msstyles.h | 24 +++++++++++++++++++++- dlls/uxtheme/property.c | 8 ++++---- dlls/uxtheme/stylemap.c | 45 ++++++++++++++++++----------------------- 4 files changed, 53 insertions(+), 30 deletions(-)
diff --git a/dlls/uxtheme/msstyles.c b/dlls/uxtheme/msstyles.c index cfd21a48989..4dcd87d3d0b 100644 --- a/dlls/uxtheme/msstyles.c +++ b/dlls/uxtheme/msstyles.c @@ -1435,6 +1435,12 @@ HRESULT MSSTYLES_GetPropertyString(PTHEME_PROPERTY tp, LPWSTR pszBuff, int cchMa return S_OK; }
+HRESULT MSSTYLES_GetPropertyStringUpper(PTHEME_PROPERTY tp, LPWSTR pszBuff, int cchMaxBuffChars) +{ + strupperW(pszBuff, tp->lpValue, min(tp->dwValueLen+1, cchMaxBuffChars)); + return S_OK; +} + /*********************************************************************** * MSSTYLES_GetPropertyRect * diff --git a/dlls/uxtheme/msstyles.h b/dlls/uxtheme/msstyles.h index 98e1aa045d6..2c75f7b00aa 100644 --- a/dlls/uxtheme/msstyles.h +++ b/dlls/uxtheme/msstyles.h @@ -21,6 +21,8 @@ #ifndef __WINE_MSSTYLES_H #define __WINE_MSSTYLES_H
+#include "winternl.h" + #define TMT_ENUM 200
#define MAX_THEME_APP_NAME 60 @@ -93,7 +95,7 @@ HRESULT MSSTYLES_SetActiveTheme(PTHEME_FILE tf, BOOL setMetrics) DECLSPEC_HIDDEN PTHEME_CLASS MSSTYLES_OpenThemeClass(LPCWSTR pszAppName, LPCWSTR pszClassList, UINT dpi) DECLSPEC_HIDDEN; HRESULT MSSTYLES_CloseThemeClass(PTHEME_CLASS tc) DECLSPEC_HIDDEN; BOOL MSSTYLES_LookupProperty(LPCWSTR pszPropertyName, int *dwPrimitive, int *dwId) DECLSPEC_HIDDEN; -BOOL MSSTYLES_LookupEnum(LPCWSTR pszValueName, int dwEnum, int *dwValue) DECLSPEC_HIDDEN; +BOOL MSSTYLES_LookupEnum(const WCHAR *enum_name, int enum_type, int *enum_value) DECLSPEC_HIDDEN; BOOL MSSTYLES_LookupPartState(LPCWSTR pszClass, LPCWSTR pszPart, LPCWSTR pszState, int *iPartId, int *iStateId) DECLSPEC_HIDDEN; PUXINI_FILE MSSTYLES_GetThemeIni(PTHEME_FILE tf) DECLSPEC_HIDDEN; UINT MSSTYLES_GetThemeDPI(PTHEME_CLASS tc) DECLSPEC_HIDDEN; @@ -110,6 +112,7 @@ HRESULT MSSTYLES_GetPropertyInt(PTHEME_PROPERTY tp, int *piVal) DECLSPEC_HIDDEN; HRESULT MSSTYLES_GetPropertyIntList(PTHEME_PROPERTY tp, INTLIST *pIntList) DECLSPEC_HIDDEN; HRESULT MSSTYLES_GetPropertyPosition(PTHEME_PROPERTY tp, POINT *pPoint) DECLSPEC_HIDDEN; HRESULT MSSTYLES_GetPropertyString(PTHEME_PROPERTY tp, LPWSTR pszBuff, int cchMaxBuffChars) DECLSPEC_HIDDEN; +HRESULT MSSTYLES_GetPropertyStringUpper(PTHEME_PROPERTY tp, LPWSTR pszBuff, int cchMaxBuffChars) DECLSPEC_HIDDEN; HRESULT MSSTYLES_GetPropertyRect(PTHEME_PROPERTY tp, RECT *pRect) DECLSPEC_HIDDEN; HRESULT MSSTYLES_GetPropertyMargins(PTHEME_PROPERTY tp, RECT *prc, MARGINS *pMargins) DECLSPEC_HIDDEN;
@@ -120,4 +123,23 @@ BOOL UXINI_FindSection(PUXINI_FILE uf, LPCWSTR lpName) DECLSPEC_HIDDEN; LPCWSTR UXINI_GetNextValue(PUXINI_FILE uf, DWORD *dwNameLen, LPCWSTR *lpValue, DWORD *dwValueLen) DECLSPEC_HIDDEN; BOOL UXINI_FindValue(PUXINI_FILE uf, LPCWSTR lpName, LPCWSTR *lpValue, DWORD *dwValueLen) DECLSPEC_HIDDEN;
+static inline WCHAR toupperW(WCHAR c) +{ + if (c >= 'a' && c <= 'z') return c - 'a' + 'A'; + else if (c > 127) return RtlUpcaseUnicodeChar(c); + else return c; +} + +static inline WCHAR *strupperW(WCHAR *dst, const WCHAR *src, DWORD count) +{ + WCHAR *d = dst; + while ((count > 1) && *src) + { + count--; + *d++ = toupperW(*src++); + } + if (count) *d = 0; + return dst; +} + #endif diff --git a/dlls/uxtheme/property.c b/dlls/uxtheme/property.c index 188f13836e2..13b3d576393 100644 --- a/dlls/uxtheme/property.c +++ b/dlls/uxtheme/property.c @@ -85,10 +85,10 @@ HRESULT WINAPI GetThemeEnumValue(HTHEME hTheme, int iPartId, int iStateId, if(!(tp = MSSTYLES_FindProperty(hTheme, iPartId, iStateId, TMT_ENUM, iPropId))) return E_PROP_ID_UNSUPPORTED;
- hr = MSSTYLES_GetPropertyString(tp, val, ARRAY_SIZE(val)); + hr = MSSTYLES_GetPropertyStringUpper(tp, val, ARRAY_SIZE(val)); if(FAILED(hr)) return hr; - if(!MSSTYLES_LookupEnum(val, iPropId, piVal)) + if (!MSSTYLES_LookupEnum(val, iPropId, piVal)) return E_PROP_ID_UNSUPPORTED; return S_OK; } @@ -260,10 +260,10 @@ HRESULT WINAPI GetThemeMetric(HTHEME hTheme, HDC hdc, int iPartId, case TMT_COLOR: return MSSTYLES_GetPropertyColor(tp, (COLORREF*)piVal); case TMT_ENUM: - hr = MSSTYLES_GetPropertyString(tp, val, ARRAY_SIZE(val)); + hr = MSSTYLES_GetPropertyStringUpper(tp, val, ARRAY_SIZE(val)); if(FAILED(hr)) return hr; - if(!MSSTYLES_LookupEnum(val, iPropId, piVal)) + if (!MSSTYLES_LookupEnum(val, iPropId, piVal)) return E_PROP_ID_UNSUPPORTED; return S_OK; case TMT_FILENAME: diff --git a/dlls/uxtheme/stylemap.c b/dlls/uxtheme/stylemap.c index e1973305076..6fdf7f894ce 100644 --- a/dlls/uxtheme/stylemap.c +++ b/dlls/uxtheme/stylemap.c @@ -35,11 +35,12 @@ typedef struct _MSSTYLES_PROPERTY_MAP { WCHAR szPropertyName[24]; } MSSTYLES_PROPERTY_MAP, *PMSSTYLES_PROPERTY_MAP;
-typedef struct _MSSTYLES_ENUM_MAP { - WORD dwEnum; - WORD dwValue; - WCHAR szValueName[18]; -} MSSTYLES_ENUM_MAP, *PMSSTYLES_ENUM_MAP; +struct enum_desc +{ + WORD enum_type; + WORD enum_value; + WCHAR enum_name[18]; +};
typedef struct _MSSTYLES_CLASS_MAP { WORD dwPartID; @@ -266,7 +267,8 @@ static const MSSTYLES_PROPERTY_MAP mapProperty[] = { * Map strings to enumeration values * Enum,Value,ValueName */ -static const MSSTYLES_ENUM_MAP mapEnum[] = { +static const struct enum_desc enum_descs[] = +{ {TMT_BGTYPE, BT_IMAGEFILE, L"IMAGEFILE"}, {TMT_BGTYPE, BT_BORDERFILL, L"BORDERFILL"}, {TMT_BGTYPE, BT_NONE, L"NONE"}, @@ -1511,31 +1513,24 @@ BOOL MSSTYLES_LookupProperty(LPCWSTR pszPropertyName, int *dwPrimitive, int *dwI return FALSE; }
-/********************************************************************** - * MSSTYLES_LookupEnum - * - * Lookup the value for an enumeration - * - * PARAMS - * pszValueName Value name to lookup - * dwEnum Enumeration property ID to search - * dwValue Location to store value - * - * RETURNS - * FALSE if value is not found, TRUE otherwise - */ -BOOL MSSTYLES_LookupEnum(LPCWSTR pszValueName, int dwEnum, int *dwValue) +/* enum_name must be upper case */ +BOOL MSSTYLES_LookupEnum(const WCHAR *enum_name, int enum_type, int *enum_value) { - DWORD item = 0; + const struct enum_desc *item = enum_descs; + /* Locate the enum block */ - while(*mapEnum[item].szValueName && mapEnum[item].dwEnum != dwEnum) item++; + while (*item->enum_name && item->enum_type != enum_type) item++; + /* Now find the value in that block */ - while(*mapEnum[item].szValueName && mapEnum[item].dwEnum == dwEnum) { - if(!lstrcmpiW(mapEnum[item].szValueName, pszValueName)) { - if(dwValue) *dwValue = mapEnum[item].dwValue; + while (*item->enum_name && item->enum_type == enum_type) + { + if (!wcscmp(item->enum_name, enum_name)) + { + if (enum_value) *enum_value = item->enum_value; return TRUE; } item++; } + return FALSE; }
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/uxtheme/msstyles.c | 4 ++-- dlls/uxtheme/msstyles.h | 2 +- dlls/uxtheme/stylemap.c | 47 ++++++++++++++++------------------------- dlls/uxtheme/system.c | 5 ++++- 4 files changed, 25 insertions(+), 33 deletions(-)
diff --git a/dlls/uxtheme/msstyles.c b/dlls/uxtheme/msstyles.c index 4dcd87d3d0b..aa1f10949ce 100644 --- a/dlls/uxtheme/msstyles.c +++ b/dlls/uxtheme/msstyles.c @@ -934,7 +934,7 @@ static void MSSTYLES_ParseThemeIni(PTHEME_FILE tf, BOOL setMetrics) parse_init_nonclient (&nonClientState);
while((lpName=UXINI_GetNextValue(ini, &dwLen, &lpValue, &dwValueLen))) { - lstrcpynW(szPropertyName, lpName, min(dwLen+1, ARRAY_SIZE(szPropertyName))); + strupperW(szPropertyName, lpName, min(dwLen + 1, ARRAY_SIZE(szPropertyName))); if(MSSTYLES_LookupProperty(szPropertyName, &iPropertyPrimitive, &iPropertyId)) { if(iPropertyId >= TMT_FIRSTCOLOR && iPropertyId <= TMT_LASTCOLOR) { if (!parse_handle_color_property (&colorState, iPropertyId, @@ -985,7 +985,7 @@ static void MSSTYLES_ParseThemeIni(PTHEME_FILE tf, BOOL setMetrics) ps = MSSTYLES_AddPartState(cls, iPartId, iStateId);
while((lpName=UXINI_GetNextValue(ini, &dwLen, &lpValue, &dwValueLen))) { - lstrcpynW(szPropertyName, lpName, min(dwLen+1, ARRAY_SIZE(szPropertyName))); + strupperW(szPropertyName, lpName, min(dwLen + 1, ARRAY_SIZE(szPropertyName))); if(MSSTYLES_LookupProperty(szPropertyName, &iPropertyPrimitive, &iPropertyId)) { MSSTYLES_AddProperty(ps, iPropertyPrimitive, iPropertyId, lpValue, dwValueLen, isGlobal); } diff --git a/dlls/uxtheme/msstyles.h b/dlls/uxtheme/msstyles.h index 2c75f7b00aa..cbb6b5b467b 100644 --- a/dlls/uxtheme/msstyles.h +++ b/dlls/uxtheme/msstyles.h @@ -94,7 +94,7 @@ void MSSTYLES_CloseThemeFile(PTHEME_FILE tf) DECLSPEC_HIDDEN; HRESULT MSSTYLES_SetActiveTheme(PTHEME_FILE tf, BOOL setMetrics) DECLSPEC_HIDDEN; PTHEME_CLASS MSSTYLES_OpenThemeClass(LPCWSTR pszAppName, LPCWSTR pszClassList, UINT dpi) DECLSPEC_HIDDEN; HRESULT MSSTYLES_CloseThemeClass(PTHEME_CLASS tc) DECLSPEC_HIDDEN; -BOOL MSSTYLES_LookupProperty(LPCWSTR pszPropertyName, int *dwPrimitive, int *dwId) DECLSPEC_HIDDEN; +BOOL MSSTYLES_LookupProperty(const WCHAR *prop_name, int *primitive, int *id) DECLSPEC_HIDDEN; BOOL MSSTYLES_LookupEnum(const WCHAR *enum_name, int enum_type, int *enum_value) DECLSPEC_HIDDEN; BOOL MSSTYLES_LookupPartState(LPCWSTR pszClass, LPCWSTR pszPart, LPCWSTR pszState, int *iPartId, int *iStateId) DECLSPEC_HIDDEN; PUXINI_FILE MSSTYLES_GetThemeIni(PTHEME_FILE tf) DECLSPEC_HIDDEN; diff --git a/dlls/uxtheme/stylemap.c b/dlls/uxtheme/stylemap.c index 6fdf7f894ce..dd54507b5a5 100644 --- a/dlls/uxtheme/stylemap.c +++ b/dlls/uxtheme/stylemap.c @@ -29,11 +29,12 @@ #define TMT_ENUM 200 #define TMT_STOCKIMAGEFILE 3007
-typedef struct _MSSTYLES_PROPERTY_MAP { - WORD dwPrimitiveType; - WORD dwPropertyID; - WCHAR szPropertyName[24]; -} MSSTYLES_PROPERTY_MAP, *PMSSTYLES_PROPERTY_MAP; +struct property_desc +{ + WORD primitive; + WORD id; + WCHAR prop_name[24]; +};
struct enum_desc { @@ -57,7 +58,8 @@ typedef struct _MSSTYLES_CLASS_NAME { * Map property names to IDs & primitive types * PrimitiveType,PropertyID,PropertyName */ -static const MSSTYLES_PROPERTY_MAP mapProperty[] = { +static const struct property_desc property_descs[] = +{ {TMT_STRING, TMT_STRING, L"STRING"}, {TMT_INT, TMT_INT, L"INT"}, {TMT_BOOL, TMT_BOOL, L"BOOL"}, @@ -1487,30 +1489,17 @@ BOOL MSSTYLES_LookupPartState(LPCWSTR pszClass, LPCWSTR pszPart, LPCWSTR pszStat return TRUE; }
-/********************************************************************** - * MSSTYLES_LookupProperty - * - * Find a property ID from name - * - * PARAMS - * pszPropertyName Name of property to lookup - * dwPrimitive Location to store primitive type of property - * dwId Location to store ID of property - * - * RETURNS - * FALSE if value is not found, TRUE otherwise - */ -BOOL MSSTYLES_LookupProperty(LPCWSTR pszPropertyName, int *dwPrimitive, int *dwId) +/* prop_name must be upper case */ +BOOL MSSTYLES_LookupProperty(const WCHAR *prop_name, int *primitive, int *id) { - DWORD item = 0; - do { - if(!lstrcmpiW(mapProperty[item].szPropertyName, pszPropertyName)) { - if(dwPrimitive) *dwPrimitive = mapProperty[item].dwPrimitiveType; - if(dwId) *dwId = mapProperty[item].dwPropertyID; - return TRUE; - } - } while(*mapProperty[++item].szPropertyName); - return FALSE; + const struct property_desc *item = property_descs; + + while (*item->prop_name && wcscmp(item->prop_name, prop_name)) item++; + if (!*item->prop_name) return FALSE; + + if (primitive) *primitive = item->primitive; + if (id) *id = item->id; + return TRUE; }
/* enum_name must be upper case */ diff --git a/dlls/uxtheme/system.c b/dlls/uxtheme/system.c index 25f495d29f3..f8a8848e97a 100644 --- a/dlls/uxtheme/system.c +++ b/dlls/uxtheme/system.c @@ -834,6 +834,7 @@ HRESULT WINAPI GetThemeDocumentationProperty(LPCWSTR pszThemeName, TMT_VERSION,5006, TMT_DESCRIPTION,5007 }; + WCHAR buffer[24];
PTHEME_FILE pt; HRESULT hr; @@ -847,7 +848,9 @@ HRESULT WINAPI GetThemeDocumentationProperty(LPCWSTR pszThemeName,
/* Try to load from string resources */ hr = E_PROP_ID_UNSUPPORTED; - if(MSSTYLES_LookupProperty(pszPropertyName, NULL, &iDocId)) { + strupperW(buffer, pszPropertyName, ARRAY_SIZE(buffer)); + if (MSSTYLES_LookupProperty(buffer, NULL, &iDocId)) + { for(i=0; i<ARRAY_SIZE(wDocToRes); i+=2) { if(wDocToRes[i] == iDocId) { if(LoadStringW(pt->hTheme, wDocToRes[i+1], pszValueBuff, cchMaxValChars)) {
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/uxtheme/stylemap.c | 253 ++++++++++++++++++++++++---------------- 1 file changed, 151 insertions(+), 102 deletions(-)
diff --git a/dlls/uxtheme/stylemap.c b/dlls/uxtheme/stylemap.c index dd54507b5a5..740f45d36d2 100644 --- a/dlls/uxtheme/stylemap.c +++ b/dlls/uxtheme/stylemap.c @@ -43,16 +43,18 @@ struct enum_desc WCHAR enum_name[18]; };
-typedef struct _MSSTYLES_CLASS_MAP { - WORD dwPartID; - WORD dwStateID; - WCHAR szName[31]; -} MSSTYLES_CLASS_MAP, *PMSSTYLES_CLASS_MAP; +struct part_desc +{ + WORD part_id; + WORD state_id; + WCHAR part_name[31]; +};
-typedef struct _MSSTYLES_CLASS_NAME { - const MSSTYLES_CLASS_MAP *lpMap; - WCHAR pszClass[12]; -} MSSTYLES_CLASS_NAME, *PMSSTYLES_CLASS_NAME; +struct class_desc +{ + const struct part_desc *parts; + WCHAR class_name[12]; +};
/*********************************************************************** * Map property names to IDs & primitive types @@ -339,7 +341,8 @@ static const struct enum_desc enum_descs[] = * Defined as PartID,StateID,TextName * If StateID == 0 then its a part being defined */ -static const MSSTYLES_CLASS_MAP classButton[] = { +static const struct part_desc button_desc[] = +{ {BP_PUSHBUTTON, 0, L"PUSHBUTTON"}, {BP_PUSHBUTTON, PBS_NORMAL, L"NORMAL"}, {BP_PUSHBUTTON, PBS_HOT, L"HOT"}, @@ -433,7 +436,8 @@ static const MSSTYLES_CLASS_MAP classButton[] = { {0, 0, L""} };
-static const MSSTYLES_CLASS_MAP classClock[] = { +static const struct part_desc clock_desc[] = +{ {CLP_TIME, 0, L"TIME"}, {CLP_TIME, CLS_NORMAL, L"NORMAL"}, {CLP_TIME, CLS_HOT, L"HOT"}, @@ -441,7 +445,8 @@ static const MSSTYLES_CLASS_MAP classClock[] = { {0, 0, L""} };
-static const MSSTYLES_CLASS_MAP classCombobox[] = { +static const struct part_desc combobox_desc[] = +{ {CP_DROPDOWNBUTTON, 0, L"DROPDOWNBUTTON"}, {CP_DROPDOWNBUTTON, CBXS_NORMAL, L"NORMAL"}, {CP_DROPDOWNBUTTON, CBXS_HOT, L"HOT"}, @@ -484,7 +489,8 @@ static const MSSTYLES_CLASS_MAP classCombobox[] = { {0, 0, L""} };
-static const MSSTYLES_CLASS_MAP classEdit[] = { +static const struct part_desc edit_desc[] = +{ {EP_EDITTEXT, 0, L"EDITTEXT"}, {EP_EDITTEXT, ETS_NORMAL, L"NORMAL"}, {EP_EDITTEXT, ETS_HOT, L"HOT"}, @@ -531,7 +537,8 @@ static const MSSTYLES_CLASS_MAP classEdit[] = { {0, 0, L""} };
-static const MSSTYLES_CLASS_MAP classExplorerbar[] = { +static const struct part_desc explorerbar_desc[] = +{ {EBP_HEADERBACKGROUND, 0, L"HEADERBACKGROUND"}, {EBP_HEADERCLOSE, 0, L"HEADERCLOSE"}, {EBP_HEADERCLOSE, EBHC_NORMAL, L"NORMAL"}, @@ -571,7 +578,8 @@ static const MSSTYLES_CLASS_MAP classExplorerbar[] = { {0, 0, L""} };
-static const MSSTYLES_CLASS_MAP classHeader[] = { +static const struct part_desc header_desc[] = +{ {HP_HEADERITEM, 0, L"HEADERITEM"}, {HP_HEADERITEM, HIS_NORMAL, L"NORMAL"}, {HP_HEADERITEM, HIS_HOT, L"HOT"}, @@ -610,7 +618,8 @@ static const MSSTYLES_CLASS_MAP classHeader[] = { {0, 0, L""} };
-static const MSSTYLES_CLASS_MAP classListview[] = { +static const struct part_desc listview_desc[] = +{ {LVP_LISTITEM, 0, L"LISTITEM"}, {LVP_LISTITEM, LISS_NORMAL, L"NORMAL"}, {LVP_LISTITEM, LISS_HOT, L"HOT"}, @@ -668,7 +677,8 @@ static const MSSTYLES_CLASS_MAP classListview[] = { {0, 0, L""} };
-static const MSSTYLES_CLASS_MAP classMenu[] = { +static const struct part_desc menu_desc[] = +{ {MENU_MENUITEM_TMSCHEMA, 0, L"MENUITEM"}, {MENU_MENUDROPDOWN_TMSCHEMA, 0, L"MENUDROPDOWN"}, {MENU_MENUBARITEM_TMSCHEMA, 0, L"MENUBARITEM"}, @@ -721,7 +731,8 @@ static const MSSTYLES_CLASS_MAP classMenu[] = { {0, 0, L""} };
-static const MSSTYLES_CLASS_MAP classMenuband[] = { +static const struct part_desc menuband_desc[] = +{ {MDP_NEWAPPBUTTON, 0, L"NEWAPPBUTTON"}, {MDP_NEWAPPBUTTON, MDS_NORMAL, L"NORMAL"}, {MDP_NEWAPPBUTTON, MDS_HOT, L"HOT"}, @@ -733,7 +744,8 @@ static const MSSTYLES_CLASS_MAP classMenuband[] = { {0, 0, L""} };
-static const MSSTYLES_CLASS_MAP classNavigation[] = { +static const struct part_desc navigation_desc[] = +{ {NAV_BACKBUTTON, 0, L"BACKBUTTON"}, {NAV_BACKBUTTON, NAV_BB_NORMAL, L"NORMAL"}, {NAV_BACKBUTTON, NAV_BB_HOT, L"HOT"}, @@ -752,7 +764,8 @@ static const MSSTYLES_CLASS_MAP classNavigation[] = { {0, 0, L""} };
-static const MSSTYLES_CLASS_MAP classPage[] = { +static const struct part_desc page_desc[] = +{ {PGRP_UP, 0, L"UP"}, {PGRP_UP, UPS_NORMAL, L"NORMAL"}, {PGRP_UP, UPS_HOT, L"HOT"}, @@ -776,7 +789,8 @@ static const MSSTYLES_CLASS_MAP classPage[] = { {0, 0, L""} };
-static const MSSTYLES_CLASS_MAP classProgress[] = { +static const struct part_desc progress_desc[] = +{ {PP_BAR, 0, L"BAR"}, {PP_BARVERT, 0, L"BARVERT"}, {PP_CHUNK, 0, L"CHUNK"}, @@ -804,7 +818,8 @@ static const MSSTYLES_CLASS_MAP classProgress[] = { {0, 0, L""} };
-static const MSSTYLES_CLASS_MAP classRebar[] = { +static const struct part_desc rebar_desc[] = +{ {RP_GRIPPER, 0, L"GRIPPER"}, {RP_GRIPPERVERT, 0, L"GRIPPERVERT"}, {RP_BAND, 0, L"BAND"}, @@ -828,7 +843,8 @@ static const MSSTYLES_CLASS_MAP classRebar[] = { {0, 0, L""} };
-static const MSSTYLES_CLASS_MAP classScrollbar[] = { +static const struct part_desc scrollbar_desc[] = +{ {SBP_ARROWBTN, 0, L"ARROWBTN"}, {SBP_ARROWBTN, ABS_UPNORMAL, L"UPNORMAL"}, {SBP_ARROWBTN, ABS_UPHOT, L"UPHOT"}, @@ -911,7 +927,8 @@ static const MSSTYLES_CLASS_MAP classScrollbar[] = { {0, 0, L""} };
-static const MSSTYLES_CLASS_MAP classSpin[] = { +static const struct part_desc spin_desc[] = +{ {SPNP_UP, 0, L"UP"}, {SPNP_UP, UPS_NORMAL, L"NORMAL"}, {SPNP_UP, UPS_HOT, L"HOT"}, @@ -935,7 +952,8 @@ static const MSSTYLES_CLASS_MAP classSpin[] = { {0, 0, L""} };
-static const MSSTYLES_CLASS_MAP classStartpanel[] = { +static const struct part_desc startpanel_desc[] = +{ {SPP_USERPANE, 0, L"USERPANE"}, {SPP_MOREPROGRAMS, 0, L"MOREPROGRAMS"}, {SPP_MOREPROGRAMSARROW, 0, L"MOREPROGRAMSARROW"}, @@ -985,14 +1003,16 @@ static const MSSTYLES_CLASS_MAP classStartpanel[] = { {0, 0, L""} };
-static const MSSTYLES_CLASS_MAP classStatus[] = { +static const struct part_desc status_desc[] = +{ {SP_PANE, 0, L"PANE"}, {SP_GRIPPERPANE, 0, L"GRIPPERPANE"}, {SP_GRIPPER, 0, L"GRIPPER"}, {0, 0, L""} };
-static const MSSTYLES_CLASS_MAP classTab[] = { +static const struct part_desc tab_desc[] = +{ {TABP_TABITEM, 0, L"TABITEM"}, {TABP_TABITEM, TIS_NORMAL, L"NORMAL"}, {TABP_TABITEM, TIS_HOT, L"HOT"}, @@ -1047,14 +1067,16 @@ static const MSSTYLES_CLASS_MAP classTab[] = { {0, 0, L""} };
-static const MSSTYLES_CLASS_MAP classTaskband[] = { +static const struct part_desc taskband_desc[] = +{ {TDP_GROUPCOUNT, 0, L"GROUPCOUNT"}, {TDP_FLASHBUTTON, 0, L"FLASHBUTTON"}, {TDP_FLASHBUTTONGROUPMENU, 0, L"FLASHBUTTONGROUPMENU"}, {0, 0, L""} };
-static const MSSTYLES_CLASS_MAP classTaskbar[] = { +static const struct part_desc taskbar_desc[] = +{ {TBP_BACKGROUNDBOTTOM, 0, L"BACKGROUNDBOTTOM"}, {TBP_BACKGROUNDRIGHT, 0, L"BACKGROUNDRIGHT"}, {TBP_BACKGROUNDTOP, 0, L"BACKGROUNDTOP"}, @@ -1066,7 +1088,8 @@ static const MSSTYLES_CLASS_MAP classTaskbar[] = { {0, 0, L""} };
-static const MSSTYLES_CLASS_MAP classTaskdialog[] = { +static const struct part_desc taskdialog_desc[] = +{ {TDLG_PRIMARYPANEL, 0, L"PRIMARYPANEL"}, {TDLG_MAININSTRUCTIONPANE, 0, L"MAININSTRUCTIONPANE"}, {TDLG_MAINICON, 0, L"MAINICON"}, @@ -1100,7 +1123,8 @@ static const MSSTYLES_CLASS_MAP classTaskdialog[] = { {0, 0, L""} };
-static const MSSTYLES_CLASS_MAP classToolbar[] = { +static const struct part_desc toolbar_desc[] = +{ {TP_BUTTON, 0, L"BUTTON"}, {TP_BUTTON, TS_NORMAL, L"NORMAL"}, {TP_BUTTON, TS_HOT, L"HOT"}, @@ -1167,7 +1191,8 @@ static const MSSTYLES_CLASS_MAP classToolbar[] = { {0, 0, L""} };
-static const MSSTYLES_CLASS_MAP classTooltip[] = { +static const struct part_desc tooltip_desc[] = +{ {TTP_STANDARD, 0, L"STANDARD"}, {TTP_STANDARD, TTSS_NORMAL, L"NORMAL"}, {TTP_STANDARD, TTSS_LINK, L"LINK"}, @@ -1198,7 +1223,8 @@ static const MSSTYLES_CLASS_MAP classTooltip[] = { {0, 0, L""} };
-static const MSSTYLES_CLASS_MAP classTrackbar[] = { +static const struct part_desc trackbar_desc[] = +{ {TKP_TRACK, 0, L"TRACK"}, {TKP_TRACK, TRS_NORMAL, L"NORMAL"}, {TKP_TRACKVERT, 0, L"TRACKVERT"}, @@ -1246,13 +1272,15 @@ static const MSSTYLES_CLASS_MAP classTrackbar[] = { {0, 0, L""} };
-static const MSSTYLES_CLASS_MAP classTraynotify[] = { +static const struct part_desc traynotify_desc[] = +{ {TNP_BACKGROUND, 0, L"BACKGROUND"}, {TNP_ANIMBACKGROUND, 0, L"ANIMBACKGROUND"}, {0, 0, L""} };
-static const MSSTYLES_CLASS_MAP classTreeview[] = { +static const struct part_desc treeview_desc[] = +{ {TVP_TREEITEM, 0, L"TREEITEM"}, {TVP_TREEITEM, TREIS_NORMAL, L"NORMAL"}, {TVP_TREEITEM, TREIS_HOT, L"HOT"}, @@ -1270,7 +1298,8 @@ static const MSSTYLES_CLASS_MAP classTreeview[] = { {0, 0, L""} };
-static const MSSTYLES_CLASS_MAP classWindow[] = { +static const struct part_desc window_desc[] = +{ {WP_CAPTION, 0, L"CAPTION"}, {WP_CAPTION, CS_ACTIVE, L"ACTIVE"}, {WP_CAPTION, CS_INACTIVE, L"INACTIVE"}, @@ -1410,82 +1439,102 @@ static const MSSTYLES_CLASS_MAP classWindow[] = { };
/* Map class names to part/state maps */ -static const MSSTYLES_CLASS_NAME mapClass[] = { - {classButton, L"BUTTON"}, - {classClock, L"CLOCK"}, - {classCombobox, L"COMBOBOX"}, - {classEdit, L"EDIT"}, - {classExplorerbar, L"EXPLORERBAR"}, - {classHeader, L"HEADER"}, - {classListview, L"LISTVIEW"}, - {classMenu, L"MENU"}, - {classMenuband, L"MENUBAND"}, - {classNavigation, L"NAVIGATION"}, - {classPage, L"PAGE"}, - {classProgress, L"PROGRESS"}, - {classRebar, L"REBAR"}, - {classScrollbar, L"SCROLLBAR"}, - {classSpin, L"SPIN"}, - {classStartpanel, L"STARTPANEL"}, - {classStatus, L"STATUS"}, - {classTab, L"TAB"}, - {classTaskband, L"TASKBAND"}, - {classTaskbar, L"TASKBAR"}, - {classTaskdialog, L"TASKDIALOG"}, - {classToolbar, L"TOOLBAR"}, - {classTooltip, L"TOOLTIP"}, - {classTrackbar, L"TRACKBAR"}, - {classTraynotify, L"TRAYNOTIFY"}, - {classTreeview, L"TREEVIEW"}, - {classWindow, L"WINDOW"} +static const struct class_desc class_descs[] = +{ + {button_desc, L"BUTTON"}, + {clock_desc, L"CLOCK"}, + {combobox_desc, L"COMBOBOX"}, + {edit_desc, L"EDIT"}, + {explorerbar_desc, L"EXPLORERBAR"}, + {header_desc, L"HEADER"}, + {listview_desc, L"LISTVIEW"}, + {menu_desc, L"MENU"}, + {menuband_desc, L"MENUBAND"}, + {navigation_desc, L"NAVIGATION"}, + {page_desc, L"PAGE"}, + {progress_desc, L"PROGRESS"}, + {rebar_desc, L"REBAR"}, + {scrollbar_desc, L"SCROLLBAR"}, + {spin_desc, L"SPIN"}, + {startpanel_desc, L"STARTPANEL"}, + {status_desc, L"STATUS"}, + {tab_desc, L"TAB"}, + {taskband_desc, L"TASKBAND"}, + {taskbar_desc, L"TASKBAR"}, + {taskdialog_desc, L"TASKDIALOG"}, + {toolbar_desc, L"TOOLBAR"}, + {tooltip_desc, L"TOOLTIP"}, + {trackbar_desc, L"TRACKBAR"}, + {traynotify_desc, L"TRAYNOTIFY"}, + {treeview_desc, L"TREEVIEW"}, + {window_desc, L"WINDOW"}, + {0}, };
-BOOL MSSTYLES_LookupPartState(LPCWSTR pszClass, LPCWSTR pszPart, LPCWSTR pszState, int *iPartId, int *iStateId) +static BOOL lookup_class_part(const struct class_desc *desc, const WCHAR *part_name, const WCHAR *state_name, int *part_id, int *state_id) { - unsigned int i; - const MSSTYLES_CLASS_MAP *map; + const struct part_desc *item = desc->parts;
- *iPartId = 0; - *iStateId = 0; - for(i=0; i<ARRAY_SIZE(mapClass); i++) { - if(!lstrcmpiW(mapClass[i].pszClass, pszClass)) { - map = mapClass[i].lpMap; - if(pszPart) { - do { - if(map->dwStateID == 0 && !lstrcmpiW(map->szName, pszPart)) { - *iPartId = map->dwPartID; - break; - } - } while(*((++map)->szName)); + if (part_name) + { + do + { + if (item->state_id == 0 && !lstrcmpiW(item->part_name, part_name)) + { + *part_id = item->part_id; + break; } - if(pszState) { - if(pszPart && *iPartId == 0) { + item++; + } while (*item->part_name); + } + + if (state_name) + { + if (part_name && *part_id == 0) return FALSE; + + do + { + if (part_name) + { + if (item->part_id == *part_id && !lstrcmpiW(item->part_name, state_name)) + { + *state_id = item->state_id; break; } - do { - if(pszPart) { - if(map->dwPartID == *iPartId && !lstrcmpiW(map->szName, pszState)) { - *iStateId = map->dwStateID; - break; - } - } - else { - if(!lstrcmpiW(map->szName, pszState)) { - *iStateId = map->dwStateID; - break; - } - } - } while(*((++map)->szName)); } - break; - } - } - if(pszPart && *iPartId == 0) { - return FALSE; + else + { + if (!lstrcmpiW(item->part_name, state_name)) + { + *state_id = item->state_id; + break; + } + } + item++; + } while (*item->part_name); } - if(pszState && *iStateId == 0) { - return FALSE; + + if (part_name && *part_id == 0) return FALSE; + if (state_name && *state_id == 0) return FALSE; + return TRUE; +} + +BOOL MSSTYLES_LookupPartState(const WCHAR *class_name, const WCHAR *part_name, const WCHAR *state_name, int *part_id, int *state_id) +{ + const struct class_desc *item = class_descs; + + *part_id = 0; + *state_id = 0; + + while (*item->class_name) + { + if (!lstrcmpiW(item->class_name, class_name)) + return lookup_class_part(item, part_name, state_name, part_id, state_id); + item++; } + + if (part_name && *part_id == 0) return FALSE; + if (state_name && *state_id == 0) return FALSE; return TRUE; }
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/uxtheme/msstyles.c | 44 ++++++++++++++++++++--------------------- dlls/uxtheme/stylemap.c | 8 ++++---- 2 files changed, 26 insertions(+), 26 deletions(-)
diff --git a/dlls/uxtheme/msstyles.c b/dlls/uxtheme/msstyles.c index aa1f10949ce..a64d518ec32 100644 --- a/dlls/uxtheme/msstyles.c +++ b/dlls/uxtheme/msstyles.c @@ -341,7 +341,7 @@ static BOOL MSSTYLES_ParseIniSectionName(LPCWSTR lpSection, DWORD dwLen, LPWSTR WCHAR state[60] = {'\0'}; LPWSTR tmp; LPWSTR comp; - lstrcpynW(sec, lpSection, min(dwLen+1, ARRAY_SIZE(sec))); + strupperW(sec, lpSection, min(dwLen+1, ARRAY_SIZE(sec)));
*szAppName = 0; *szClassName = 0; @@ -353,47 +353,47 @@ static BOOL MSSTYLES_ParseIniSectionName(LPCWSTR lpSection, DWORD dwLen, LPWSTR if(tmp) { *tmp++ = 0; tmp++; - lstrcpynW(szAppName, comp, MAX_THEME_APP_NAME); + strupperW(szAppName, comp, MAX_THEME_APP_NAME); comp = tmp; }
tmp = wcschr(comp, '.'); if(tmp) { *tmp++ = 0; - lstrcpynW(szClassName, comp, MAX_THEME_CLASS_NAME); + strupperW(szClassName, comp, MAX_THEME_CLASS_NAME); comp = tmp; /* now get the part & state */ tmp = wcschr(comp, '('); if(tmp) { *tmp++ = 0; - lstrcpynW(part, comp, ARRAY_SIZE(part)); + strupperW(part, comp, ARRAY_SIZE(part)); comp = tmp; /* now get the state */ tmp = wcschr(comp, ')'); if (!tmp) return FALSE; *tmp = 0; - lstrcpynW(state, comp, ARRAY_SIZE(state)); + strupperW(state, comp, ARRAY_SIZE(state)); } else { - lstrcpynW(part, comp, ARRAY_SIZE(part)); + strupperW(part, comp, ARRAY_SIZE(part)); } } else { tmp = wcschr(comp, '('); if(tmp) { *tmp++ = 0; - lstrcpynW(szClassName, comp, MAX_THEME_CLASS_NAME); + strupperW(szClassName, comp, MAX_THEME_CLASS_NAME); comp = tmp; /* now get the state */ tmp = wcschr(comp, ')'); if (!tmp) return FALSE; *tmp = 0; - lstrcpynW(state, comp, ARRAY_SIZE(state)); + strupperW(state, comp, ARRAY_SIZE(state)); } else { - lstrcpynW(szClassName, comp, MAX_THEME_CLASS_NAME); + strupperW(szClassName, comp, MAX_THEME_CLASS_NAME); } } if(!*szClassName) return FALSE; @@ -418,11 +418,11 @@ static PTHEME_CLASS MSSTYLES_FindClass(PTHEME_FILE tf, LPCWSTR pszAppName, LPCWS PTHEME_CLASS cur = tf->classes; while(cur) { if(!pszAppName) { - if(!*cur->szAppName && !lstrcmpiW(pszClassName, cur->szClassName)) + if(!*cur->szAppName && !wcscmp(pszClassName, cur->szClassName)) return cur; } else { - if(!lstrcmpiW(pszAppName, cur->szAppName) && !lstrcmpiW(pszClassName, cur->szClassName)) + if(!wcscmp(pszAppName, cur->szAppName) && !wcscmp(pszClassName, cur->szClassName)) return cur; } cur = cur->next; @@ -978,7 +978,7 @@ static void MSSTYLES_ParseThemeIni(PTHEME_FILE tf, BOOL setMetrics) } if(MSSTYLES_ParseIniSectionName(lpName, dwLen, szAppName, szClassName, &iPartId, &iStateId)) { BOOL isGlobal = FALSE; - if(!lstrcmpiW(szClassName, L"globals")) { + if(!wcscmp(szClassName, L"GLOBALS")) { isGlobal = TRUE; } cls = MSSTYLES_AddClass(tf, szAppName, szClassName); @@ -997,7 +997,7 @@ static void MSSTYLES_ParseThemeIni(PTHEME_FILE tf, BOOL setMetrics) }
/* App/Class combos override values defined by the base class, map these overrides */ - globals = MSSTYLES_FindClass(tf, NULL, L"globals"); + globals = MSSTYLES_FindClass(tf, NULL, L"GLOBALS"); cls = tf->classes; while(cls) { if(*cls->szAppName) { @@ -1052,13 +1052,13 @@ PTHEME_CLASS MSSTYLES_OpenThemeClass(LPCWSTR pszAppName, LPCWSTR pszClassList, U start = pszClassList; while((end = wcschr(start, ';'))) { len = end-start; - lstrcpynW(szClassName, start, min(len+1, ARRAY_SIZE(szClassName))); + strupperW(szClassName, start, min(len+1, ARRAY_SIZE(szClassName))); start = end+1; cls = MSSTYLES_FindClass(tfActiveTheme, pszAppName, szClassName); if(cls) break; } if(!cls && *start) { - lstrcpynW(szClassName, start, ARRAY_SIZE(szClassName)); + strupperW(szClassName, start, ARRAY_SIZE(szClassName)); cls = MSSTYLES_FindClass(tfActiveTheme, pszAppName, szClassName); } if(cls) { @@ -1189,7 +1189,7 @@ HBITMAP MSSTYLES_LoadBitmap (PTHEME_CLASS tc, LPCWSTR lpFilename, BOOL* hasAlpha WCHAR szFile[MAX_PATH]; LPWSTR tmp; PTHEME_IMAGE img; - lstrcpynW(szFile, lpFilename, ARRAY_SIZE(szFile)); + strupperW(szFile, lpFilename, ARRAY_SIZE(szFile)); tmp = szFile; do { if(*tmp == '\') *tmp = '_'; @@ -1201,7 +1201,7 @@ HBITMAP MSSTYLES_LoadBitmap (PTHEME_CLASS tc, LPCWSTR lpFilename, BOOL* hasAlpha img = tc->tf->images; while (img) { - if (lstrcmpiW (szFile, img->name) == 0) + if (wcscmp(szFile, img->name) == 0) { TRACE ("found %p %s: %p\n", img, debugstr_w (img->name), img->image); *hasAlpha = img->hasAlpha; @@ -1270,7 +1270,7 @@ static BOOL MSSTYLES_GetNextToken(LPCWSTR lpStringStart, LPCWSTR lpStringEnd, LP end = cur; while(isSpace(*end)) end--;
- lstrcpynW(lpBuff, start, min(buffSize, end-start+1)); + strupperW(lpBuff, start, min(buffSize, end-start+1));
if(lpValEnd) *lpValEnd = cur; return TRUE; @@ -1344,10 +1344,10 @@ static HRESULT MSSTYLES_GetFont (LPCWSTR lpCur, LPCWSTR lpEnd, pFont->lfWeight = FW_REGULAR; pFont->lfCharSet = DEFAULT_CHARSET; while(MSSTYLES_GetNextToken(lpCur, lpEnd, &lpCur, attr, ARRAY_SIZE(attr))) { - if(!lstrcmpiW(L"bold", attr)) pFont->lfWeight = FW_BOLD; - else if(!lstrcmpiW(L"italic", attr)) pFont->lfItalic = TRUE; - else if(!lstrcmpiW(L"underline", attr)) pFont->lfUnderline = TRUE; - else if(!lstrcmpiW(L"strikeout", attr)) pFont->lfStrikeOut = TRUE; + if(!wcscmp(L"BOLD", attr)) pFont->lfWeight = FW_BOLD; + else if(!wcscmp(L"ITALIC", attr)) pFont->lfItalic = TRUE; + else if(!wcscmp(L"UNDERLINE", attr)) pFont->lfUnderline = TRUE; + else if(!wcscmp(L"STRIKEOUT", attr)) pFont->lfStrikeOut = TRUE; } *lpValEnd = lpCur; return S_OK; diff --git a/dlls/uxtheme/stylemap.c b/dlls/uxtheme/stylemap.c index 740f45d36d2..1fe28a2b2e8 100644 --- a/dlls/uxtheme/stylemap.c +++ b/dlls/uxtheme/stylemap.c @@ -1479,7 +1479,7 @@ static BOOL lookup_class_part(const struct class_desc *desc, const WCHAR *part_n { do { - if (item->state_id == 0 && !lstrcmpiW(item->part_name, part_name)) + if (item->state_id == 0 && !wcscmp(item->part_name, part_name)) { *part_id = item->part_id; break; @@ -1496,7 +1496,7 @@ static BOOL lookup_class_part(const struct class_desc *desc, const WCHAR *part_n { if (part_name) { - if (item->part_id == *part_id && !lstrcmpiW(item->part_name, state_name)) + if (item->part_id == *part_id && !wcscmp(item->part_name, state_name)) { *state_id = item->state_id; break; @@ -1504,7 +1504,7 @@ static BOOL lookup_class_part(const struct class_desc *desc, const WCHAR *part_n } else { - if (!lstrcmpiW(item->part_name, state_name)) + if (!wcscmp(item->part_name, state_name)) { *state_id = item->state_id; break; @@ -1528,7 +1528,7 @@ BOOL MSSTYLES_LookupPartState(const WCHAR *class_name, const WCHAR *part_name, c
while (*item->class_name) { - if (!lstrcmpiW(item->class_name, class_name)) + if (!wcscmp(item->class_name, class_name)) return lookup_class_part(item, part_name, state_name, part_id, state_id); item++; }
I took that opportunity to cleanup the style as I think I saw it being done, if that's not the case or not desired I can undo the style changes.
Instead, convert strings to uppercase beforehand in a locale-independent way, and compare with wcscmp.
You should be able to achieve the same results by using CompareStringOrdinal, without the need to convert strings.
On Mon Dec 5 10:36:32 2022 +0000, Alexandre Julliard wrote:
Instead, convert strings to uppercase beforehand in a
locale-independent way, and compare with wcscmp. You should be able to achieve the same results by using CompareStringOrdinal, without the need to convert strings.
Most of the time the strings were copied to some local buffers already, so I think converting them to uppercase at the same time makes sense. I think it's also slightly more efficient as the same string is often compared in a loop with many others.
Zhiyi Zhang (@zhiyi) commented about dlls/uxtheme/msstyles.h:
LPCWSTR UXINI_GetNextValue(PUXINI_FILE uf, DWORD *dwNameLen, LPCWSTR *lpValue, DWORD *dwValueLen) DECLSPEC_HIDDEN; BOOL UXINI_FindValue(PUXINI_FILE uf, LPCWSTR lpName, LPCWSTR *lpValue, DWORD *dwValueLen) DECLSPEC_HIDDEN;
+static inline WCHAR toupperW(WCHAR c) +{
- if (c >= 'a' && c <= 'z') return c - 'a' + 'A';
- else if (c > 127) return RtlUpcaseUnicodeChar(c);
- else return c;
+}
+static inline WCHAR *strupperW(WCHAR *dst, const WCHAR *src, DWORD count)
Can't you use CharUpperBuffW() instead?
Zhiyi Zhang (@zhiyi) commented about dlls/uxtheme/stylemap.c:
WCHAR szPropertyName[24];
} MSSTYLES_PROPERTY_MAP, *PMSSTYLES_PROPERTY_MAP;
-typedef struct _MSSTYLES_ENUM_MAP {
- WORD dwEnum;
- WORD dwValue;
- WCHAR szValueName[18];
-} MSSTYLES_ENUM_MAP, *PMSSTYLES_ENUM_MAP; +struct enum_desc
Please put the style changes in a separate commit.
Zhiyi Zhang (@zhiyi) commented about dlls/uxtheme/stylemap.c:
-/**********************************************************************
MSSTYLES_LookupEnum
- Lookup the value for an enumeration
- PARAMS
pszValueName Value name to lookup
dwEnum Enumeration property ID to search
dwValue Location to store value
- RETURNS
FALSE if value is not found, TRUE otherwise
- */
-BOOL MSSTYLES_LookupEnum(LPCWSTR pszValueName, int dwEnum, int *dwValue) +/* enum_name must be upper case */ +BOOL MSSTYLES_LookupEnum(const WCHAR *enum_name, int enum_type, int *enum_value)
MSSTYLES_LookupEnum() is always used with MSSTYLES_GetPropertyString(). So I think we can introduce a MSSTYLES_GetPropertyEnumValue() and keep all the upper-case conversions there and remove MSSTYLES_LookupEnum().
I have doubts about this series. Surely using wcscmp() is more efficient. But it means future developers always have to worry about using the correct case. Also is it the real bottleneck? Maybe we can use an alternate data structure. For example, store enums of the same type in an array to reduce look-up time and see how much we can reduce.
Zhiyi Zhang (@zhiyi) commented about dlls/uxtheme/stylemap.c:
-/**********************************************************************
MSSTYLES_LookupProperty
- Find a property ID from name
- PARAMS
pszPropertyName Name of property to lookup
dwPrimitive Location to store primitive type of property
dwId Location to store ID of property
- RETURNS
FALSE if value is not found, TRUE otherwise
- */
-BOOL MSSTYLES_LookupProperty(LPCWSTR pszPropertyName, int *dwPrimitive, int *dwId) +/* prop_name must be upper case */ +BOOL MSSTYLES_LookupProperty(const WCHAR *prop_name, int *primitive, int *id)
I think it's better to do the upper-case conversion inside MSSTYLES_LookupProperty() in the case. So the people calling this function don't have to bother about case matching.
Zhiyi Zhang (@zhiyi) commented about dlls/uxtheme/stylemap.c:
- {status_desc, L"STATUS"},
- {tab_desc, L"TAB"},
- {taskband_desc, L"TASKBAND"},
- {taskbar_desc, L"TASKBAR"},
- {taskdialog_desc, L"TASKDIALOG"},
- {toolbar_desc, L"TOOLBAR"},
- {tooltip_desc, L"TOOLTIP"},
- {trackbar_desc, L"TRACKBAR"},
- {traynotify_desc, L"TRAYNOTIFY"},
- {treeview_desc, L"TREEVIEW"},
- {window_desc, L"WINDOW"},
- {0},
};
-BOOL MSSTYLES_LookupPartState(LPCWSTR pszClass, LPCWSTR pszPart, LPCWSTR pszState, int *iPartId, int *iStateId) +static BOOL lookup_class_part(const struct class_desc *desc, const WCHAR *part_name, const WCHAR *state_name, int *part_id, int *state_id)
Splitting this function doesn't look better to me.
On Tue Dec 6 09:32:54 2022 +0000, Zhiyi Zhang wrote:
Can't you use CharUpperBuffW() instead?
`CharUpperBuffW` uses `LCMapStringW` which I believe is still locale-dependent and does a lot more than `RtlUpcaseUnicodeChar`. I don't think any of this is required here. Most of the time we're even comparing ASCII strings.
Also is it the real bottleneck?
Yes. It saves ~1min on every Gitlab CI test run, which is ~3.5% of the total time. The main part being the winetest.exe initialization, which runs every test to query its test list.
Maybe we can use an alternate data structure. For example, store enums of the same type in an array to reduce look-up time and see how much we can reduce.
I don't know, I think there's no reason to use lstrcmpiW here except for convenience. There's a few places where the strings may be dynamic but most of the time we're even comparing static ASCII strings. I didn't write tests but I doubt even the dynamic strings are locale-dependent.