Core/Analytics: Use std::string_view where applicable
In these cases, the strings are treated as views anyways, so we can use them here to avoid potential allocations.
This commit is contained in:
1 parent
2c2b9690bb
commit
a5caa95a4b
2 files changed
+8
-7
No files matched your search
@@ -101,11 +101,11 @@ void DolphinAnalytics::GenerateNewIdentity()
|
||||
SConfig::GetInstance().SaveSettings();
|
||||
}
|
||||
|
||||
std::string DolphinAnalytics::MakeUniqueId(const std::string& data)
|
||||
std::string DolphinAnalytics::MakeUniqueId(std::string_view data)
|
||||
{
|
||||
u8 digest[20];
|
||||
std::string input = m_unique_id + data;
|
||||
mbedtls_sha1(reinterpret_cast<const u8*>(input.c_str()), input.size(), digest);
|
||||
std::array<u8, 20> digest;
|
||||
const auto input = std::string{m_unique_id}.append(data);
|
||||
mbedtls_sha1(reinterpret_cast<const u8*>(input.c_str()), input.size(), digest.data());
|
||||
|
||||
// Convert to hex string and truncate to 64 bits.
|
||||
std::string out;
|
||||
@@ -116,7 +116,7 @@ std::string DolphinAnalytics::MakeUniqueId(const std::string& data)
|
||||
return out;
|
||||
}
|
||||
|
||||
void DolphinAnalytics::ReportDolphinStart(const std::string& ui_type)
|
||||
void DolphinAnalytics::ReportDolphinStart(std::string_view ui_type)
|
||||
{
|
||||
Common::AnalyticsReportBuilder builder(m_base_builder);
|
||||
builder.AddData("type", "dolphin-start");
|
||||
|
||||
Reference in new issue
Block a user