From 987a90842b4f55aaddbf21ca4b5bf1aa4606be70 Mon Sep 17 00:00:00 2001 From: Shamser Ahmed Date: Fri, 20 Dec 2024 13:52:19 +0000 Subject: [PATCH] HPCC-31003 Move instead of copying object to improve performance Signed-off-by: Shamser Ahmed --- common/workunit/workunit.cpp | 2 +- system/jlib/jstats.cpp | 2 +- system/jlib/jstats.h | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/common/workunit/workunit.cpp b/common/workunit/workunit.cpp index 8e42207db59..112caeb9a7e 100644 --- a/common/workunit/workunit.cpp +++ b/common/workunit/workunit.cpp @@ -2708,7 +2708,7 @@ void StatisticsAggregator::recordStats(IStatisticCollection * sourceStats, unsig verifyex(graphScopeId.setScopeText(graphName)); StatsScopeId wfScopeId(SSTworkflow, wfid); StatsScopeId sgScopeId(SSTsubgraph, sgId); - statsCollection->recordStats(mapping, sourceStats, {wfScopeId, graphScopeId, sgScopeId}); + statsCollection->recordStats(mapping, sourceStats, {std::move(wfScopeId), std::move(graphScopeId), std::move(sgScopeId)}); } // Recalculate aggregates and then write the aggregates to global stats (dali) diff --git a/system/jlib/jstats.cpp b/system/jlib/jstats.cpp index bba06151c6f..9daa4b671cc 100644 --- a/system/jlib/jstats.cpp +++ b/system/jlib/jstats.cpp @@ -2242,7 +2242,7 @@ class CStatisticCollection : public CInterfaceOf ++scopeItem; } - CStatisticCollection * tgtScopeCollection = ensureSubScopePath(path); + CStatisticCollection * tgtScopeCollection = ensureSubScopePath(std::move(path)); bool wasUpdated = false; // More efficient to iterate over stats rather than mapping... ForEachItemIn(i, curSrcCollection->stats) diff --git a/system/jlib/jstats.h b/system/jlib/jstats.h index 14414235266..43c5bd441e5 100644 --- a/system/jlib/jstats.h +++ b/system/jlib/jstats.h @@ -43,8 +43,8 @@ inline constexpr stat_type statPercent(stat_type value) { return (stat_type)(va inline constexpr stat_type statPercentageOf(stat_type value, stat_type per) { return value * per / 10000; } inline StatisticKind queryStatsVariant(StatisticKind kind) { return (StatisticKind)(kind & ~StKindMask); } -inline cost_type money2cost_type(double money) { return money * 1E6; } -inline double cost_type2money(cost_type cost) { return ((double) cost) / 1E6; } +constexpr cost_type money2cost_type(const double money) { return money * 1E6; } +constexpr double cost_type2money(cost_type cost) { return ((double) cost) / 1E6; } extern jlib_decl void formatTime(StringBuffer & out, unsigned __int64 value); //---------------------------------------------------------------------------------------------------------------------