From 0b45e8d9058dfe4dda3248de8e19198fab215311 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. [ROCm/clr commit: cecc0782efcf4f43e6f1c7eda36677e827941651] --- projects/clr/hipamd/hipify-clang/src/Cuda2Hip.cpp | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/projects/clr/hipamd/hipify-clang/src/Cuda2Hip.cpp b/projects/clr/hipamd/hipify-clang/src/Cuda2Hip.cpp index bc4bdb4587..af44f84ba2 100644 --- a/projects/clr/hipamd/hipify-clang/src/Cuda2Hip.cpp +++ b/projects/clr/hipamd/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) {