[PATCH 05/17] shell32/autocomplete: Reduce the strlen calls because they are redundant
Gabriel Ivăncescu
gabrielopcode at gmail.com
Wed Sep 5 11:13:07 CDT 2018
We can retrieve the length of the string from the SendMessage calls already.
Signed-off-by: Gabriel Ivăncescu <gabrielopcode at gmail.com>
---
dlls/shell32/autocomplete.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/dlls/shell32/autocomplete.c b/dlls/shell32/autocomplete.c
index 3d3ec57..e5712e6 100644
--- a/dlls/shell32/autocomplete.c
+++ b/dlls/shell32/autocomplete.c
@@ -195,14 +195,16 @@ static LRESULT APIENTRY ACEditSubclassProc(HWND hwnd, UINT uMsg, WPARAM wParam,
UINT len = SendMessageW(This->hwndListBox, LB_GETTEXTLEN, sel, 0);
if ((msg = heap_alloc((len + 1)*sizeof(WCHAR)))) {
- SendMessageW(This->hwndListBox, LB_GETTEXT, sel, (LPARAM)msg);
+ len = SendMessageW(This->hwndListBox, LB_GETTEXT, sel, (LPARAM)msg);
SendMessageW(hwnd, WM_SETTEXT, 0, (LPARAM)msg);
- SendMessageW(hwnd, EM_SETSEL, lstrlenW(msg), lstrlenW(msg));
+ SendMessageW(hwnd, EM_SETSEL, len, len);
heap_free(msg);
}
} else {
+ UINT len;
SendMessageW(hwnd, WM_SETTEXT, 0, (LPARAM)This->txtbackup);
- SendMessageW(hwnd, EM_SETSEL, lstrlenW(This->txtbackup), lstrlenW(This->txtbackup));
+ len = strlenW(This->txtbackup);
+ SendMessageW(hwnd, EM_SETSEL, len, len);
}
}
return 0;
@@ -320,9 +322,9 @@ static LRESULT APIENTRY ACLBoxSubclassProc(HWND hwnd, UINT uMsg, WPARAM wParam,
break;
len = SendMessageW(This->hwndListBox, LB_GETTEXTLEN, sel, 0);
if ((msg = heap_alloc((len + 1)*sizeof(WCHAR)))) {
- SendMessageW(hwnd, LB_GETTEXT, sel, (LPARAM)msg);
+ len = SendMessageW(hwnd, LB_GETTEXT, sel, (LPARAM)msg);
SendMessageW(This->hwndEdit, WM_SETTEXT, 0, (LPARAM)msg);
- SendMessageW(This->hwndEdit, EM_SETSEL, 0, lstrlenW(msg));
+ SendMessageW(This->hwndEdit, EM_SETSEL, 0, len);
ShowWindow(hwnd, SW_HIDE);
heap_free(msg);
}
--
1.9.1
More information about the wine-devel
mailing list