Skip to content

Commit

Permalink
Reduce work done in global constructors (#501)
Browse files Browse the repository at this point in the history
  • Loading branch information
ras0219-msft authored Apr 11, 2022
1 parent 66d7ca3 commit f92f59b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
7 changes: 2 additions & 5 deletions src/vcpkg/base/hash.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,10 @@ namespace vcpkg::Hash

struct BCryptHasher : Hasher
{
static const BCRYPT_ALG_HANDLE sha256_alg_handle;
static const BCRYPT_ALG_HANDLE sha512_alg_handle;

explicit BCryptHasher(Algorithm algo) noexcept
{
static const BCRYPT_ALG_HANDLE sha256_alg_handle = get_alg_handle(BCRYPT_SHA256_ALGORITHM);
static const BCRYPT_ALG_HANDLE sha512_alg_handle = get_alg_handle(BCRYPT_SHA512_ALGORITHM);
switch (algo)
{
case Algorithm::Sha256: alg_handle = sha256_alg_handle; break;
Expand Down Expand Up @@ -183,8 +182,6 @@ namespace vcpkg::Hash
BCRYPT_ALG_HANDLE alg_handle = nullptr;
};

const BCRYPT_ALG_HANDLE BCryptHasher::sha256_alg_handle = get_alg_handle(BCRYPT_SHA256_ALGORITHM);
const BCRYPT_ALG_HANDLE BCryptHasher::sha512_alg_handle = get_alg_handle(BCRYPT_SHA512_ALGORITHM);
#else

template<class WordTy>
Expand Down
4 changes: 2 additions & 2 deletions src/vcpkg/metrics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,9 @@ namespace vcpkg

struct MetricMessage
{
std::string user_id = generate_random_UUID();
std::string user_id;
std::string user_timestamp;
std::string timestamp = get_current_date_time_string();
std::string timestamp;

Json::Object properties;
Json::Object measurements;
Expand Down

0 comments on commit f92f59b

Please sign in to comment.