mirror of
https://github.com/electron/electron.git
synced 2026-01-08 23:18:06 -05:00
refactor: avoid a few unnecessary strings (#47644)
* perf: replace string temporary with string_view in GetXdgAppId() * perf: replace string temporary with string_view in ToV8(WindowOpenDisposition) * perf: replace string temporary with string_view in ToV8(electron::api::WebContents::Type)
This commit is contained in:
@@ -242,7 +242,7 @@ template <>
|
||||
struct Converter<WindowOpenDisposition> {
|
||||
static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
|
||||
WindowOpenDisposition val) {
|
||||
std::string disposition = "other";
|
||||
std::string_view disposition = "other";
|
||||
switch (val) {
|
||||
case WindowOpenDisposition::CURRENT_TAB:
|
||||
disposition = "default";
|
||||
@@ -303,7 +303,7 @@ struct Converter<electron::api::WebContents::Type> {
|
||||
static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
|
||||
electron::api::WebContents::Type val) {
|
||||
using Type = electron::api::WebContents::Type;
|
||||
std::string type;
|
||||
std::string_view type;
|
||||
switch (val) {
|
||||
case Type::kBackgroundPage:
|
||||
type = "backgroundPage";
|
||||
|
||||
@@ -430,7 +430,7 @@ std::optional<std::string> GetDesktopName() {
|
||||
|
||||
std::string GetXdgAppId() {
|
||||
if (std::optional<std::string> desktop_file_name = GetDesktopName()) {
|
||||
const std::string kDesktopExtension{".desktop"};
|
||||
constexpr std::string_view kDesktopExtension = ".desktop";
|
||||
if (base::EndsWith(*desktop_file_name, kDesktopExtension,
|
||||
base::CompareCase::INSENSITIVE_ASCII)) {
|
||||
desktop_file_name->resize(desktop_file_name->size() -
|
||||
|
||||
Reference in New Issue
Block a user