Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Bevenius <daniel.bevenius@gmail.com>2020-06-02 12:12:38 +0300
committerDaniel Bevenius <daniel.bevenius@gmail.com>2020-06-05 06:58:49 +0300
commit3e2a3007107b7a100794f4e4adbde19263fc7464 (patch)
tree5b91ea11a0f8db004cce85c1933aa9c44c7dd09b /src/node_credentials.cc
parent7232c2a1604d241ce0455d919ba9b0b8e9959f81 (diff)
src: use ToLocal in SafeGetenv
This commit replaces the IsEmpty call to use ToLocal instead which allows for the following ToLocalChecked function call to be avoided. PR-URL: https://github.com/nodejs/node/pull/33695 Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: David Carlier <devnexen@gmail.com>
Diffstat (limited to 'src/node_credentials.cc')
-rw-r--r--src/node_credentials.cc7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/node_credentials.cc b/src/node_credentials.cc
index d7be988d978..d552a501726 100644
--- a/src/node_credentials.cc
+++ b/src/node_credentials.cc
@@ -44,12 +44,13 @@ bool SafeGetenv(const char* key, std::string* text, Environment* env) {
if (env != nullptr) {
HandleScope handle_scope(env->isolate());
TryCatch ignore_errors(env->isolate());
- MaybeLocal<String> value = env->env_vars()->Get(
+ MaybeLocal<String> maybe_value = env->env_vars()->Get(
env->isolate(),
String::NewFromUtf8(env->isolate(), key, NewStringType::kNormal)
.ToLocalChecked());
- if (value.IsEmpty()) goto fail;
- String::Utf8Value utf8_value(env->isolate(), value.ToLocalChecked());
+ Local<String> value;
+ if (!maybe_value.ToLocal(&value)) goto fail;
+ String::Utf8Value utf8_value(env->isolate(), value);
if (*utf8_value == nullptr) goto fail;
*text = std::string(*utf8_value, utf8_value.length());
return true;