Source: Simplify hasher object construction

This commit is contained in:
Brad King
2024-01-18 17:18:10 -05:00
parent c0734d5507
commit 2352dcc830
2 changed files with 6 additions and 7 deletions

View File

@@ -8319,14 +8319,14 @@ bool cmGeneratorTarget::DiscoverSyntheticTargets(cmSyntheticTargetCache& cache,
}
if (gt->HaveCxx20ModuleSources()) {
auto hasher = cmCryptoHash::New("SHA3_512");
cmCryptoHash hasher(cmCryptoHash::AlgoSHA3_512);
constexpr size_t HASH_TRUNCATION = 12;
auto dirhash = hasher->HashString(
auto dirhash = hasher.HashString(
gt->GetLocalGenerator()->GetCurrentBinaryDirectory());
std::string safeName = gt->GetName();
cmSystemTools::ReplaceString(safeName, ":", "_");
auto targetIdent =
hasher->HashString(cmStrCat("@d_", dirhash, "@u_", usage.GetHash()));
hasher.HashString(cmStrCat("@d_", dirhash, "@u_", usage.GetHash()));
std::string targetName =
cmStrCat(safeName, "@synth_", targetIdent.substr(0, HASH_TRUNCATION));

View File

@@ -4,7 +4,6 @@
#include "cmImportedCxxModuleInfo.h"
#include <cstddef>
#include <memory>
#include <string>
#include <utility>
#include <vector>
@@ -60,13 +59,13 @@ std::string ImportedCxxModuleLookup::BmiNameForSource(std::string const& path)
auto importit = this->ImportedInfo.find(path);
std::string bmiName;
auto hasher = cmCryptoHash::New("SHA3_512");
cmCryptoHash hasher(cmCryptoHash::AlgoSHA3_512);
constexpr size_t HASH_TRUNCATION = 12;
if (importit != this->ImportedInfo.end()) {
auto safename = hasher->HashString(importit->second.Name);
auto safename = hasher.HashString(importit->second.Name);
bmiName = cmStrCat(safename.substr(0, HASH_TRUNCATION), ".bmi");
} else {
auto dirhash = hasher->HashString(path);
auto dirhash = hasher.HashString(path);
bmiName = cmStrCat(dirhash.substr(0, HASH_TRUNCATION), ".bmi");
}