mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-23 06:09:50 -06:00
Common/Analytics: Convert std::string overload into std::string_view
Allows for both string types to be non-allocating. We can't remove the const char* overload in this case due to the fact that pointers can implicitly convert to bool, so if we removed the overload all const char arrays passed in would begin executing the bool overload instead of the string_view overload, which is definitely not what we want to occur.
This commit is contained in:
@ -76,15 +76,19 @@ AnalyticsReportBuilder::AnalyticsReportBuilder()
|
||||
m_report.push_back(WIRE_FORMAT_VERSION);
|
||||
}
|
||||
|
||||
void AnalyticsReportBuilder::AppendSerializedValue(std::string* report, const std::string& v)
|
||||
void AnalyticsReportBuilder::AppendSerializedValue(std::string* report, std::string_view v)
|
||||
{
|
||||
AppendType(report, TypeId::STRING);
|
||||
AppendBytes(report, reinterpret_cast<const u8*>(v.data()), static_cast<u32>(v.size()));
|
||||
}
|
||||
|
||||
// We can't remove this overload despite the string_view overload due to the fact that
|
||||
// pointers can implicitly convert to bool, so if we removed the overload, then all
|
||||
// const char strings passed in would begin forwarding to the bool overload,
|
||||
// which is definitely not what we want to occur.
|
||||
void AnalyticsReportBuilder::AppendSerializedValue(std::string* report, const char* v)
|
||||
{
|
||||
AppendSerializedValue(report, std::string(v));
|
||||
AppendSerializedValue(report, std::string_view(v));
|
||||
}
|
||||
|
||||
void AnalyticsReportBuilder::AppendSerializedValue(std::string* report, bool v)
|
||||
|
Reference in New Issue
Block a user