summaryrefslogtreecommitdiffstatshomepage
path: root/src/lib/util/hashing.cpp
diff options
context:
space:
mode:
author Miodrag Milanovic <mmicko@gmail.com>2015-12-03 18:17:25 +0100
committer Miodrag Milanovic <mmicko@gmail.com>2015-12-03 18:17:25 +0100
commit91605d3f4df9b9fb1490c276053ff274fb728816 (patch)
treeec89d290d9bfba3b27d4aa28336a5ac9a9d45a7a /src/lib/util/hashing.cpp
parent5232ca932afe0acc8c3ef2bd3599e04a8c7def69 (diff)
clang-modernize part 1 (nw)
Diffstat (limited to 'src/lib/util/hashing.cpp')
-rw-r--r--src/lib/util/hashing.cpp16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/lib/util/hashing.cpp b/src/lib/util/hashing.cpp
index e7f315ecc53..785127e01e8 100644
--- a/src/lib/util/hashing.cpp
+++ b/src/lib/util/hashing.cpp
@@ -63,13 +63,13 @@ bool sha1_t::from_string(const char *string, int length)
return false;
// iterate through our raw buffer
- for (int bytenum = 0; bytenum < sizeof(m_raw); bytenum++)
+ for (auto & elem : m_raw)
{
int upper = char_to_hex(*string++);
int lower = char_to_hex(*string++);
if (upper == -1 || lower == -1)
return false;
- m_raw[bytenum] = (upper << 4) | lower;
+ elem = (upper << 4) | lower;
}
return true;
}
@@ -82,8 +82,8 @@ bool sha1_t::from_string(const char *string, int length)
const char *sha1_t::as_string(std::string &buffer) const
{
buffer.clear();
- for (int i = 0; i < ARRAY_LENGTH(m_raw); i++)
- strcatprintf(buffer, "%02x", m_raw[i]);
+ for (auto & elem : m_raw)
+ strcatprintf(buffer, "%02x", elem);
return buffer.c_str();
}
@@ -106,13 +106,13 @@ bool md5_t::from_string(const char *string, int length)
return false;
// iterate through our raw buffer
- for (int bytenum = 0; bytenum < sizeof(m_raw); bytenum++)
+ for (auto & elem : m_raw)
{
int upper = char_to_hex(*string++);
int lower = char_to_hex(*string++);
if (upper == -1 || lower == -1)
return false;
- m_raw[bytenum] = (upper << 4) | lower;
+ elem = (upper << 4) | lower;
}
return true;
}
@@ -125,8 +125,8 @@ bool md5_t::from_string(const char *string, int length)
const char *md5_t::as_string(std::string &buffer) const
{
buffer.clear();
- for (int i = 0; i < ARRAY_LENGTH(m_raw); i++)
- strcatprintf(buffer, "%02x", m_raw[i]);
+ for (auto & elem : m_raw)
+ strcatprintf(buffer, "%02x", elem);
return buffer.c_str();
}