mirror of
https://github.com/electron/electron.git
synced 2026-04-10 03:01:51 -04:00
perf: prefer base::StringPiece over std::string for build-time strings (#38736)
* perf: use base::StringPiece in InclusionStatusToString() The strings are all build-time constants and this is a private function Co-authored-by: Charles Kerr <charles@charleskerr.com> * perf: use base::StringPiece in ErrorCodeToString() The strings are all build-time constants and this is a private function Co-authored-by: Charles Kerr <charles@charleskerr.com> * perf: use base::StringPiece in MessageSourceToString() The strings are all build-time constants and this is a private function Co-authored-by: Charles Kerr <charles@charleskerr.com> * perf: use base::StringPiece in CursorTypeToString() The strings are all build-time constants and this is a private function Co-authored-by: Charles Kerr <charles@charleskerr.com> * perf: use base::StringPiece in MediaStreamTypeToString() The strings are all build-time constants and this is a private function Co-authored-by: Charles Kerr <charles@charleskerr.com> * perf: use base::StringPiece in ModifiersToArray() The strings are all build-time constants and this is a private function Co-authored-by: Charles Kerr <charles@charleskerr.com> * perf: use base::StringPiece in WebFrameRenderer::MaybeGetRenderFrame() The strings are all build-time constants and this is a private function 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:
@@ -10,6 +10,7 @@
|
||||
|
||||
#include "base/command_line.h"
|
||||
#include "base/memory/memory_pressure_listener.h"
|
||||
#include "base/strings/string_util.h"
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
#include "components/spellcheck/renderer/spellcheck.h"
|
||||
#include "content/public/renderer/render_frame.h"
|
||||
@@ -383,7 +384,7 @@ class WebFrameRenderer : public gin::Wrappable<WebFrameRenderer>,
|
||||
|
||||
private:
|
||||
bool MaybeGetRenderFrame(v8::Isolate* isolate,
|
||||
const std::string& method_name,
|
||||
const base::StringPiece method_name,
|
||||
content::RenderFrame** render_frame_ptr) {
|
||||
std::string error_msg;
|
||||
if (!MaybeGetRenderFrame(&error_msg, method_name, render_frame_ptr)) {
|
||||
@@ -394,13 +395,13 @@ class WebFrameRenderer : public gin::Wrappable<WebFrameRenderer>,
|
||||
}
|
||||
|
||||
bool MaybeGetRenderFrame(std::string* error_msg,
|
||||
const std::string& method_name,
|
||||
const base::StringPiece method_name,
|
||||
content::RenderFrame** render_frame_ptr) {
|
||||
auto* frame = render_frame();
|
||||
if (!frame) {
|
||||
*error_msg = "Render frame was torn down before webFrame." + method_name +
|
||||
" could be "
|
||||
"executed";
|
||||
*error_msg = base::StreamableToString(
|
||||
"Render frame was torn down before webFrame.", method_name,
|
||||
" could be executed");
|
||||
return false;
|
||||
}
|
||||
*render_frame_ptr = frame;
|
||||
|
||||
Reference in New Issue
Block a user