Skip to content

Commit

Permalink
hash-util: use the hex_lower algorithm
Browse files Browse the repository at this point in the history
... to optimize out the extra traversal step to lower the output string.

Closes: csutils#200
  • Loading branch information
kdudka committed Aug 27, 2024
1 parent 7ec65b1 commit a35987d
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions src/lib/hash-util.hh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
#include <vector>

#include <boost/algorithm/hex.hpp>
#include <boost/algorithm/string.hpp>

/// compute TEng hash of `src` and return it as hex-encoded string
template <typename TEng, typename TSrc>
Expand All @@ -43,9 +42,6 @@ std::string hexHashStr(const TSrc &src)

// convert the hash to a hex string
std::string result;
boost::algorithm::hex(hash.begin(), hash.end(), back_inserter(result));

// convert uppercase letters to lowercase
boost::algorithm::to_lower(result);
boost::algorithm::hex_lower(hash.begin(), hash.end(), back_inserter(result));
return result;
}

0 comments on commit a35987d

Please sign in to comment.