From d8beee891855dfe23c97e7d1e0a4179185fd040e Mon Sep 17 00:00:00 2001 From: Chris Kitching Date: Wed, 25 Oct 2017 19:42:46 +0100 Subject: [PATCH] Update counter maps sanely operator[] default-constructs the map value if no value exists for that key. Default-construction of int yields a zero. So all the manual faffing around is just unnecessary. --- hipify-clang/src/Cuda2Hip.cpp | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/hipify-clang/src/Cuda2Hip.cpp b/hipify-clang/src/Cuda2Hip.cpp index bc4bdb4587..af44f84ba2 100644 --- a/hipify-clang/src/Cuda2Hip.cpp +++ b/hipify-clang/src/Cuda2Hip.cpp @@ -181,18 +181,9 @@ protected: map = cuda2hipUnconverted; mapTotal = cuda2hipUnconvertedTotal; } - auto found = map.find(cudaName); - if (found == map.end()) { - map.insert(std::pair(cudaName, 1)); - } else { - found->second++; - } - auto foundT = mapTotal.find(cudaName); - if (foundT == mapTotal.end()) { - mapTotal.insert(std::pair(cudaName, 1)); - } else { - foundT->second++; - } + + map[cudaName]++; + mapTotal[cudaName]++; } virtual void updateCounters(const hipCounter &counter, const std::string &cudaName) {