@@ -61,6 +61,12 @@ const std::set<std::string> ErrorLogger::mCriticalErrorIds{
6161 " unknownMacro"
6262};
6363
64+ static std::size_t sdbm (const std::string& hashString) {
65+ return std::accumulate (hashString.cbegin (), hashString.cend (), std::size_t {0 }, [](std::size_t h, unsigned char c) {
66+ return static_cast <std::size_t >(c) + (h << 6 ) + (h << 16 ) - h;
67+ });
68+ }
69+
6470ErrorMessage::ErrorMessage ()
6571 : severity(Severity::none), cwe(0U ), certainty(Certainty::normal)
6672{}
@@ -311,9 +317,7 @@ void ErrorMessage::calculateWarningHash(const std::list<const Token*>& callstack
311317
312318 // hash algorithm: sdbm
313319 // any hash algorithm can be used but it has to be the same hash on different platforms and compilers
314- hash = std::accumulate (hashString.cbegin (), hashString.cend (), std::size_t {0 }, [](std::size_t h, unsigned char c) {
315- return static_cast <std::size_t >(c) + (h << 6 ) + (h << 16 ) - h;
316- });
320+ hash = sdbm (hashString);
317321}
318322
319323void ErrorMessage::calculateWarningHashFromLocations ()
@@ -328,9 +332,7 @@ void ErrorMessage::calculateWarningHashFromLocations()
328332
329333 // hash algorithm: sdbm
330334 // any hash algorithm can be used but it has to be the same hash on different platforms and compilers
331- hash = std::accumulate (hashString.cbegin (), hashString.cend (), std::size_t {0 }, [](std::size_t h, unsigned char c) {
332- return static_cast <std::size_t >(c) + (h << 6 ) + (h << 16 ) - h;
333- });
335+ hash = sdbm (hashString);
334336}
335337
336338static void serializeString (std::string &oss, const std::string & str)
0 commit comments