From 3fa7fac4dff790bb11e974f1fbef05027ce5e3bf Mon Sep 17 00:00:00 2001 From: Vyacheslav Ivanov Date: Fri, 2 Aug 2024 02:22:07 +0300 Subject: [PATCH] fix: optimization: PVS-Studio warning V830 Replaced 'std::optional::value()' with '*' operator to improve performance. Using 'std::optional::value()' involves additional overhead compared to using the '*' or '->' operators. This change ensures more efficient access to the underlying value of the optional when you are certain that it contains a value. Reported by: PVS-Studio Signed-off-by: Vyacheslav Ivanov --- src/logic/PlayerController.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/logic/PlayerController.cpp b/src/logic/PlayerController.cpp index 5bab584d..dec48579 100644 --- a/src/logic/PlayerController.cpp +++ b/src/logic/PlayerController.cpp @@ -455,7 +455,7 @@ void PlayerController::updateEntityInteraction(entityid_t eid, bool lclick, bool if (!entityOpt.has_value()) { return; } - auto entity = entityOpt.value(); + auto entity = *entityOpt; if (lclick) { scripting::on_attacked(entity, player.get(), player->getEntity()); }