From 077dc07b039031551ed243259078e3cad227f56c Mon Sep 17 00:00:00 2001 From: hiikariri Date: Thu, 28 Dec 2023 20:08:29 +0700 Subject: [PATCH] fix: use shared_ptr & unordered_map, minimize hashmap search --- include/akushon/action/model/action.hpp | 2 +- src/akushon/action/model/action.cpp | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/include/akushon/action/model/action.hpp b/include/akushon/action/model/action.hpp index d3d2b41..fe64c65 100644 --- a/include/akushon/action/model/action.hpp +++ b/include/akushon/action/model/action.hpp @@ -63,7 +63,7 @@ class Action bool is_using_spline() const; void generate_splines(); - std::map joint_splines; + std::unordered_map> joint_splines; private: std::string name; diff --git a/src/akushon/action/model/action.cpp b/src/akushon/action/model/action.cpp index 1099bdf..bf4ecc6 100644 --- a/src/akushon/action/model/action.cpp +++ b/src/akushon/action/model/action.cpp @@ -125,11 +125,11 @@ void Action::generate_splines() joint_splines.clear(); for (auto pose : poses) { for (auto & joint : pose.get_joints()) { - uint8_t joint_id = joint.get_id(); - if (joint_splines.find(joint_id) == joint_splines.end()) { - joint_splines[joint_id] = std::make_shared().get(); + const auto it = joint_splines.find(joint.get_id()); + if (it == joint_splines.end()) { + joint_splines.emplace(joint.get_id(), std::make_shared()); } - joint_splines[joint_id]->add_point(joint.get_position(), pose.get_time()); + it->second->add_point(joint.get_position(), pose.get_time()); } } }