refactor: prefer inline constexpr string_view
for string constants (#44405)
* refactor: BaseWindow::OnExecuteAppCommand() now takes a std::string_view * refactor: NativeWindow::NotifyWindowExecuteAppCommand() takes a std::string_view * refactor: AppCommandToString() returns a std::string_view, is now constexpr * refactor: make kBrowserBackward, kBrowserForward inline constexpr std::string_view Xref: https://abseil.io/tips/140 https://groups.google.com/a/chromium.org/g/chromium-dev/c/jROTxMo_m2Q/m/HgciN2KsAgAJ * refactor: use inline constexpr string_view for kDevice*Key constants Xref: https://abseil.io/tips/140 https://groups.google.com/a/chromium.org/g/chromium-dev/c/jROTxMo_m2Q/m/HgciN2KsAgAJ * refactor: IsEnvSet now takes a base::cstring_view * refactor: use inline constexpr cstring_view for kRunAsNode * refactor: use inline constexpr string_view for kPDF*PluginName * refactor: use base::FilePath::FromASCII() since "internal-pdf-viewer" is ascii * chore: remove unused shell/common/electron_constants.cc * fixup! refactor: IsEnvSet now takes a base::cstring_view
This commit is contained in:
parent
cc3359f126
commit
b3c2e83243
14 changed files with 41 additions and 59 deletions
|
@ -5,10 +5,12 @@
|
|||
#include <cstdlib>
|
||||
#include <memory>
|
||||
|
||||
#include "base/strings/cstring_view.h"
|
||||
#include "electron/fuses.h"
|
||||
#include "electron/mas.h"
|
||||
#include "shell/app/electron_library_main.h"
|
||||
#include "shell/app/uv_stdio_fix.h"
|
||||
#include "shell/common/electron_constants.h"
|
||||
|
||||
#if defined(HELPER_EXECUTABLE) && !IS_MAS_BUILD()
|
||||
#include <mach-o/dyld.h>
|
||||
|
@ -27,9 +29,9 @@ void abort_report_np(const char* fmt, ...);
|
|||
|
||||
namespace {
|
||||
|
||||
bool IsEnvSet(const char* name) {
|
||||
char* indicator = getenv(name);
|
||||
return indicator && indicator[0] != '\0';
|
||||
[[nodiscard]] bool IsEnvSet(const base::cstring_view name) {
|
||||
const char* const indicator = getenv(name.c_str());
|
||||
return indicator && *indicator;
|
||||
}
|
||||
|
||||
#if defined(HELPER_EXECUTABLE) && !IS_MAS_BUILD()
|
||||
|
@ -51,8 +53,7 @@ bool IsEnvSet(const char* name) {
|
|||
int main(int argc, char* argv[]) {
|
||||
FixStdioStreams();
|
||||
|
||||
if (electron::fuses::IsRunAsNodeEnabled() &&
|
||||
IsEnvSet("ELECTRON_RUN_AS_NODE")) {
|
||||
if (electron::fuses::IsRunAsNodeEnabled() && IsEnvSet(electron::kRunAsNode)) {
|
||||
return ElectronInitializeICUandStartNode(argc, argv);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue