fix: optimization: PVS-Studio warning V821

Creating variables in a more localized scope can enhance performance and make the code easier to understand.

Reported by: PVS-Studio
Signed-off-by: Vyacheslav Ivanov <islavaivanov76@gmail.com>
This commit is contained in:
Vyacheslav Ivanov
2024-08-03 17:50:04 +03:00
committed by MihailRis
parent 3fa7fac4df
commit 26ff0f133a
4 changed files with 5 additions and 5 deletions
+2 -2
View File
@@ -324,8 +324,6 @@ static int l_gui_getattr(lua::State* L) {
auto docname = lua::require_string(L, 1);
auto element = lua::require_string(L, 2);
auto attr = lua::require_string(L, 3);
auto docnode = getDocumentNode(L, docname, element);
auto node = docnode.node;
static const std::unordered_map<std::string_view, std::function<int(UINode*,lua::State*)>> getters {
{"color", p_get_color},
@@ -367,6 +365,8 @@ static int l_gui_getattr(lua::State* L) {
};
auto func = getters.find(attr);
if (func != getters.end()) {
auto docnode = getDocumentNode(L, docname, element);
auto node = docnode.node;
return func->second(node.get(), L);
}
return 0;