refactor: avoid a few unnecessary strings (#47655)
* perf: replace string temporary with string_view in GetXdgAppId() Co-authored-by: Charles Kerr <charles@charleskerr.com> * perf: replace string temporary with string_view in ToV8(WindowOpenDisposition) Co-authored-by: Charles Kerr <charles@charleskerr.com> * perf: replace string temporary with string_view in ToV8(electron::api::WebContents::Type) Co-authored-by: Charles Kerr <charles@charleskerr.com> --------- Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Charles Kerr <charles@charleskerr.com>
This commit is contained in:
parent
7907443448
commit
3a6d7e0c22
2 changed files with 3 additions and 3 deletions
|
@ -242,7 +242,7 @@ template <>
|
||||||
struct Converter<WindowOpenDisposition> {
|
struct Converter<WindowOpenDisposition> {
|
||||||
static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
|
static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
|
||||||
WindowOpenDisposition val) {
|
WindowOpenDisposition val) {
|
||||||
std::string disposition = "other";
|
std::string_view disposition = "other";
|
||||||
switch (val) {
|
switch (val) {
|
||||||
case WindowOpenDisposition::CURRENT_TAB:
|
case WindowOpenDisposition::CURRENT_TAB:
|
||||||
disposition = "default";
|
disposition = "default";
|
||||||
|
@ -303,7 +303,7 @@ struct Converter<electron::api::WebContents::Type> {
|
||||||
static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
|
static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
|
||||||
electron::api::WebContents::Type val) {
|
electron::api::WebContents::Type val) {
|
||||||
using Type = electron::api::WebContents::Type;
|
using Type = electron::api::WebContents::Type;
|
||||||
std::string type;
|
std::string_view type;
|
||||||
switch (val) {
|
switch (val) {
|
||||||
case Type::kBackgroundPage:
|
case Type::kBackgroundPage:
|
||||||
type = "backgroundPage";
|
type = "backgroundPage";
|
||||||
|
|
|
@ -430,7 +430,7 @@ std::optional<std::string> GetDesktopName() {
|
||||||
|
|
||||||
std::string GetXdgAppId() {
|
std::string GetXdgAppId() {
|
||||||
if (std::optional<std::string> desktop_file_name = GetDesktopName()) {
|
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,
|
if (base::EndsWith(*desktop_file_name, kDesktopExtension,
|
||||||
base::CompareCase::INSENSITIVE_ASCII)) {
|
base::CompareCase::INSENSITIVE_ASCII)) {
|
||||||
desktop_file_name->resize(desktop_file_name->size() -
|
desktop_file_name->resize(desktop_file_name->size() -
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue