perf: remove unnecessary .c_str() calls (#41869)

* perf: remove unnecessary c_str() call when invoking promise.RejectWithErrorMessage()

RejectWithErrorMessage() takes a std::string_view

* perf: remove unnecessary c_str() call when invoking Environment::SetVar()

the val arg to Environment::SetVar() takes a const std::string&

* refactor: use string_view variant of base::UTF8ToWide()

* perf: remove unnecessary c_str() call when instantiating a ScopedHString

ScopedHString has always taken a StringPiece

* refactor: use simpler invocation of base::make_span()

* perf: remove unnecessary c_str() call when calling base::CommandLine::HasSwitch()

HasSwitch() already takes a string_piece

* perf: remove unnecessary c_str() call when calling net::HttpResponseHeaders::AddHeader()

AddHeader() already takes a StringPiece arg

* perf: omit unnecessary str -> wstr -> str conversion in DesktopCapturer::UpdateSourcesList()

this conversion was made redundant by c670e38
This commit is contained in:
Charles Kerr 2024-04-16 18:48:54 -05:00 committed by GitHub
parent c670e38b4b
commit b428315c6d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 8 additions and 14 deletions

View file

@ -399,11 +399,7 @@ void DesktopCapturer::UpdateSourcesList(DesktopMediaList* list) {
int device_name_index = 0;
for (auto& source : screen_sources) {
const auto& device_name = device_names[device_name_index++];
std::wstring wide_device_name;
base::UTF8ToWide(device_name.c_str(), device_name.size(),
&wide_device_name);
const int64_t device_id =
base::PersistentHash(base::WideToUTF8(wide_device_name.c_str()));
const int64_t device_id = base::PersistentHash(device_name);
source.display_id = base::NumberToString(device_id);
}
}