From 1abde9ba888785138d8f87d478890628e66669fe Mon Sep 17 00:00:00 2001 From: Tsarevich Dmitry Date: Sun, 23 Feb 2020 19:06:19 +0300 Subject: [PATCH] [perf] Pass struct argument by pointer Do not waste performance on unneeded copy. --- src/rufus.c | 2 +- src/ui.c | 10 ++++++---- src/ui.h | 2 +- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/rufus.c b/src/rufus.c index b20aaf4c..08bda425 100755 --- a/src/rufus.c +++ b/src/rufus.c @@ -2307,7 +2307,7 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA SendMessage(hMultiToolbar, TB_GETRECT, (WPARAM)IDC_ABOUT, (LPARAM)&rc); MapWindowPoints(hDlg, NULL, (POINT*)&rc, 2); rc.left += cbw / 2; - ShowLanguageMenu(rc); + ShowLanguageMenu(&rc); break; case IDC_SETTINGS: MyDialogBox(hMainInstance, IDD_UPDATE_POLICY, hDlg, UpdateCallback); diff --git a/src/ui.c b/src/ui.c index 32fc07b8..0eb43f69 100644 --- a/src/ui.c +++ b/src/ui.c @@ -1489,7 +1489,7 @@ void UpdateProgressWithInfo(int op, int msg, uint64_t processed, uint64_t total) } } -void ShowLanguageMenu(RECT rcExclude) +void ShowLanguageMenu(const RECT *rcExclude) { TPMPARAMS tpm; HMENU menu; @@ -1500,6 +1500,8 @@ void ShowLanguageMenu(RECT rcExclude) char *search = "()"; char *l, *r, *str; + assert(rcExclude); + UM_LANGUAGE_MENU_MAX = UM_LANGUAGE_MENU; menu = CreatePopupMenu(); list_for_each_entry(lcmd, &locale_list, loc_cmd, list) { @@ -1526,11 +1528,11 @@ void ShowLanguageMenu(RECT rcExclude) // Open the menu such that it doesn't overlap the specified rect tpm.cbSize = sizeof(TPMPARAMS); - tpm.rcExclude = rcExclude; + tpm.rcExclude = *rcExclude; TrackPopupMenuEx(menu, 0, // In RTL languages, the menu should be placed at the bottom-right of the rect - right_to_left_mode ? rcExclude.right : rcExclude.left, - rcExclude.bottom + adjust, hMainDialog, &tpm); + right_to_left_mode ? rcExclude->right : rcExclude->left, + rcExclude->bottom + adjust, hMainDialog, &tpm); DestroyMenu(menu); } diff --git a/src/ui.h b/src/ui.h index be8a4489..70e41ac2 100644 --- a/src/ui.h +++ b/src/ui.h @@ -100,7 +100,7 @@ extern void ToggleImageOptions(void); extern void CreateSmallButtons(HWND hDlg); extern void CreateAdditionalControls(HWND hDlg); extern void InitProgress(BOOL bOnlyFormat); -extern void ShowLanguageMenu(RECT rcExclude); +extern void ShowLanguageMenu(const RECT *rcExclude); extern void SetPassesTooltip(void); extern void SetBootTypeDropdownWidth(void); extern void OnPaint(HDC hdc);