From 84122c5f075b0a7fb9ecd4be3a016ee0dc90fae7 Mon Sep 17 00:00:00 2001 From: Gleb Mazovetskiy Date: Tue, 20 Apr 2021 04:28:34 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=A8=20DiabloUI:=20Replace=20`dynamic?= =?UTF-8?q?=5Fcast`=20with=20`static=5Fcast`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The type is known here so we do not need to pay the overhead of a `dynamic_cast`. Follow-up to https://github.com/diasurgical/devilutionX/commit/94f385a46b3c15fd0f5b2cf3ceb8e66df6e75bd5 --- Source/DiabloUI/diabloui.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Source/DiabloUI/diabloui.cpp b/Source/DiabloUI/diabloui.cpp index 936195fca..75c2f93c3 100644 --- a/Source/DiabloUI/diabloui.cpp +++ b/Source/DiabloUI/diabloui.cpp @@ -95,7 +95,7 @@ void UiInitList(int count, void (*fnFocus)(int value), void (*fnSelect)(int valu textInputActive = false; for (auto &item : items) { if (item->m_type == UI_EDIT) { - auto *pItemUIEdit = dynamic_cast(item); + auto *pItemUIEdit = static_cast(item); SDL_SetTextInputRect(&item->m_rect); textInputActive = true; #ifdef __SWITCH__ @@ -895,13 +895,13 @@ bool HandleMouseEvent(const SDL_Event &event, UiItemBase *item) return false; switch (item->m_type) { case UI_ART_TEXT_BUTTON: - return HandleMouseEventArtTextButton(event, dynamic_cast(item)); + return HandleMouseEventArtTextButton(event, static_cast(item)); case UI_BUTTON: - return HandleMouseEventButton(event, dynamic_cast(item)); + return HandleMouseEventButton(event, static_cast(item)); case UI_LIST: - return HandleMouseEventList(event, dynamic_cast(item)); + return HandleMouseEventList(event, static_cast(item)); case UI_SCROLLBAR: - return HandleMouseEventScrollBar(event, dynamic_cast(item)); + return HandleMouseEventScrollBar(event, static_cast(item)); default: return false; } @@ -945,7 +945,7 @@ bool UiItemMouseEvents(SDL_Event *event, std::vector items) scrollBarState.downArrowPressed = scrollBarState.upArrowPressed = false; for (auto &item : items) { if (item->m_type == UI_BUTTON) - HandleGlobalMouseUpButton(dynamic_cast(item)); + HandleGlobalMouseUpButton(static_cast(item)); } }