From b383199765711302fde80e44e0307a7ace33bf8b Mon Sep 17 00:00:00 2001 From: Milian Wolff Date: Mon, 4 Jan 2016 22:41:47 +0100 Subject: [PATCH] Use std::tie instead of std::make_tuple for lexicographical ordering. std::tie takes the arguments by reference, whereas make_tuple copies them. We want the former. See also: http://www.cppsamples.com/common-tasks/lexicographic-ordering.html --- accumulatedtracedata.h | 8 ++++---- gui/parser.cpp | 3 ++- heaptrack_interpret.cpp | 8 ++++---- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/accumulatedtracedata.h b/accumulatedtracedata.h index b3c6c88..e00958c 100644 --- a/accumulatedtracedata.h +++ b/accumulatedtracedata.h @@ -42,14 +42,14 @@ struct InstructionPointer bool compareWithoutAddress(const InstructionPointer &other) const { - return std::make_tuple(moduleIndex, functionIndex, fileIndex, line) - < std::make_tuple(other.moduleIndex, other.functionIndex, other.fileIndex, other.line); + return std::tie(moduleIndex, functionIndex, fileIndex, line) + < std::tie(other.moduleIndex, other.functionIndex, other.fileIndex, other.line); } bool equalWithoutAddress(const InstructionPointer &other) const { - return std::make_tuple(moduleIndex, functionIndex, fileIndex, line) - == std::make_tuple(other.moduleIndex, other.functionIndex, other.fileIndex, other.line); + return std::tie(moduleIndex, functionIndex, fileIndex, line) + == std::tie(other.moduleIndex, other.functionIndex, other.fileIndex, other.line); } }; diff --git a/gui/parser.cpp b/gui/parser.cpp index 6acb7c9..6bbf03e 100644 --- a/gui/parser.cpp +++ b/gui/parser.cpp @@ -264,7 +264,8 @@ struct ParserData final : public AccumulatedTraceData uint64_t allocations; bool operator<(const CountedAllocationInfo& rhs) const { - return make_tuple(info.size, allocations) < make_tuple(rhs.info.size, rhs.allocations); + return tie(info.size, allocations) + < tie(rhs.info.size, rhs.allocations); } }; vector allocationInfoCounter; diff --git a/heaptrack_interpret.cpp b/heaptrack_interpret.cpp index 3e289fd..8845be3 100644 --- a/heaptrack_interpret.cpp +++ b/heaptrack_interpret.cpp @@ -111,14 +111,14 @@ struct Module bool operator<(const Module& module) const { - return make_tuple(addressStart, addressEnd, moduleIndex) - < make_tuple(module.addressStart, module.addressEnd, module.moduleIndex); + return tie(addressStart, addressEnd, moduleIndex) + < tie(module.addressStart, module.addressEnd, module.moduleIndex); } bool operator!=(const Module& module) const { - return make_tuple(addressStart, addressEnd, moduleIndex) - != make_tuple(module.addressStart, module.addressEnd, module.moduleIndex); + return tie(addressStart, addressEnd, moduleIndex) + != tie(module.addressStart, module.addressEnd, module.moduleIndex); } uintptr_t addressStart; -- 2.7.4