Module: wine Branch: master Commit: 8ee1e3453e2e714241bcaac0cd75f4af3f828c8d URL: https://source.winehq.org/git/wine.git/?a=commit;h=8ee1e3453e2e714241bcaac0c...
Author: Gabriel Ivăncescu gabrielopcode@gmail.com Date: Thu Apr 4 14:39:49 2019 +0300
comctl32/button: Use WM_GETTEXTLENGTH to see if the button has any text.
There's no reason to allocate and then parse the entire string just to see if its length is zero.
Signed-off-by: Gabriel Ivăncescu gabrielopcode@gmail.com Signed-off-by: Nikolay Sivov nsivov@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
dlls/comctl32/button.c | 30 +++++++++--------------------- 1 file changed, 9 insertions(+), 21 deletions(-)
diff --git a/dlls/comctl32/button.c b/dlls/comctl32/button.c index f282abf..5338ef8 100644 --- a/dlls/comctl32/button.c +++ b/dlls/comctl32/button.c @@ -1276,20 +1276,16 @@ static BOOL GB_GetIdealSize(BUTTON_INFO *infoPtr, SIZE *size) static BOOL CB_GetIdealSize(BUTTON_INFO *infoPtr, SIZE *size) { LONG style = GetWindowLongW(infoPtr->hwnd, GWL_STYLE); - WCHAR *text = get_button_text(infoPtr); HDC hdc; HFONT hfont; SIZE labelSize; INT textOffset; - INT textLength = 0; double scaleX; double scaleY; LONG checkboxWidth, checkboxHeight; LONG maxWidth = 0;
- if (text) textLength = lstrlenW(text); - heap_free(text); - if (textLength == 0) + if (SendMessageW(infoPtr->hwnd, WM_GETTEXTLENGTH, 0, 0) == 0) { BUTTON_GetClientRectSize(infoPtr, size); return TRUE; @@ -1325,26 +1321,18 @@ static BOOL CB_GetIdealSize(BUTTON_INFO *infoPtr, SIZE *size)
static BOOL PB_GetIdealSize(BUTTON_INFO *infoPtr, SIZE *size) { - WCHAR *text = get_button_text(infoPtr); SIZE labelSize; - INT textLength = 0;
- if (text) textLength = lstrlenW(text); - - if (textLength == 0) - { + if (SendMessageW(infoPtr->hwnd, WM_GETTEXTLENGTH, 0, 0) == 0) BUTTON_GetClientRectSize(infoPtr, size); - heap_free(text); - return TRUE; - } - heap_free(text); - - /* Ideal size include text size even if image only flags(BS_ICON, BS_BITMAP) are specified */ - BUTTON_GetLabelIdealSize(infoPtr, size->cx, &labelSize); - - size->cx = labelSize.cx; - size->cy = labelSize.cy; + else + { + /* Ideal size include text size even if image only flags(BS_ICON, BS_BITMAP) are specified */ + BUTTON_GetLabelIdealSize(infoPtr, size->cx, &labelSize);
+ size->cx = labelSize.cx; + size->cy = labelSize.cy; + } return TRUE; }