From 337fc151e4b2682de4c3b2496045e4054080b844 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Fri, 24 Jul 2009 12:11:15 +0200 Subject: simplify CAnalyzerCCpp::CreateHash Signed-off-by: Denys Vlasenko --- lib/Plugins/CCpp.cpp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'lib/Plugins/CCpp.cpp') diff --git a/lib/Plugins/CCpp.cpp b/lib/Plugins/CCpp.cpp index 176a77a..7d302c7 100644 --- a/lib/Plugins/CCpp.cpp +++ b/lib/Plugins/CCpp.cpp @@ -78,12 +78,19 @@ std::string CAnalyzerCCpp::CreateHash(const std::string& pInput) HASH_End(hc, hash, &len, sizeof(hash)); HASH_Destroy(hc); - unsigned int ii; - std::stringstream ss; - for (ii = 0; ii < len; ii++) - ss << std::setw(2) << std::setfill('0') << std::hex << (hash[ii]&0xff); + char hash_str[SHA1_LENGTH*2 + 1]; + char *d = hash_str; + unsigned char *s = hash; + while (len) + { + *d++ = "0123456789abcdef"[*s >> 4]; + *d++ = "0123456789abcdef"[*s & 0xf]; + s++; + len--; + } + *d = '\0'; - return ss.str(); + return hash_str; } void CAnalyzerCCpp::InstallDebugInfos(const std::string& pPackage) -- cgit