Skip to content

Commit 814126c

Browse files
RaisinTentargos
authored andcommitted
src,fs: remove ToLocalChecked() call from fs::AfterMkdirp()
This merges the `IsEmpty()` call and the `ToLocalChecked()` call into a single `ToLocal()` call. Signed-off-by: Darshan Sen <[email protected]> PR-URL: #40386 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Anna Henningsen <[email protected]>
1 parent 5a588ff commit 814126c

File tree

1 file changed

+11
-16
lines changed

1 file changed

+11
-16
lines changed

src/node_file.cc

+11-16
Original file line numberDiff line numberDiff line change
@@ -714,24 +714,19 @@ void FromNamespacedPath(std::string* path) {
714714
void AfterMkdirp(uv_fs_t* req) {
715715
FSReqBase* req_wrap = FSReqBase::from_req(req);
716716
FSReqAfterScope after(req_wrap, req);
717-
718-
MaybeLocal<Value> path;
719-
Local<Value> error;
720-
721717
if (after.Proceed()) {
722-
if (!req_wrap->continuation_data()->first_path().empty()) {
723-
std::string first_path(req_wrap->continuation_data()->first_path());
724-
FromNamespacedPath(&first_path);
725-
path = StringBytes::Encode(req_wrap->env()->isolate(), first_path.c_str(),
726-
req_wrap->encoding(),
727-
&error);
728-
if (path.IsEmpty())
729-
req_wrap->Reject(error);
730-
else
731-
req_wrap->Resolve(path.ToLocalChecked());
732-
} else {
733-
req_wrap->Resolve(Undefined(req_wrap->env()->isolate()));
718+
std::string first_path(req_wrap->continuation_data()->first_path());
719+
if (first_path.empty())
720+
return req_wrap->Resolve(Undefined(req_wrap->env()->isolate()));
721+
FromNamespacedPath(&first_path);
722+
Local<Value> path;
723+
Local<Value> error;
724+
if (!StringBytes::Encode(req_wrap->env()->isolate(), first_path.c_str(),
725+
req_wrap->encoding(),
726+
&error).ToLocal(&path)) {
727+
return req_wrap->Reject(error);
734728
}
729+
return req_wrap->Resolve(path);
735730
}
736731
}
737732

0 commit comments

Comments
 (0)