From 063bdc3fa611376cefeaccb0e3fd7bb992b7ca86 Mon Sep 17 00:00:00 2001 From: Patryk Wrobel Date: Mon, 22 Aug 2022 22:19:08 +0000 Subject: [PATCH] Do not redundantly call std::to_string() multiple times This change removes unneeded recalculation of hash as well as redundant calls to std::to_string(). Signed-off-by: Patryk Wrobel --- shared/source/compiler_interface/compiler_cache.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/shared/source/compiler_interface/compiler_cache.cpp b/shared/source/compiler_interface/compiler_cache.cpp index 800ca65b27..92e93b7a75 100644 --- a/shared/source/compiler_interface/compiler_cache.cpp +++ b/shared/source/compiler_interface/compiler_cache.cpp @@ -40,9 +40,13 @@ const std::string CompilerCache::getCachedFileName(const HardwareInfo &hwInfo, c hash.update("----", 4); hash.update(safePodCast(&hwInfo.platform), sizeof(hwInfo.platform)); hash.update("----", 4); - hash.update(safePodCast(std::to_string(hwInfo.featureTable.asHash()).c_str()), std::to_string(hwInfo.featureTable.asHash()).length()); + + const auto featureTableHashStr = std::to_string(hwInfo.featureTable.asHash()); + hash.update(featureTableHashStr.c_str(), featureTableHashStr.length()); hash.update("----", 4); - hash.update(safePodCast(std::to_string(hwInfo.workaroundTable.asHash()).c_str()), std::to_string(hwInfo.workaroundTable.asHash()).length()); + + const auto workaroundTableHashStr = std::to_string(hwInfo.workaroundTable.asHash()); + hash.update(workaroundTableHashStr.c_str(), workaroundTableHashStr.length()); auto res = hash.finish(); std::stringstream stream;