Skip to content

Commit

Permalink
src,fs: remove ToLocalChecked() call from fs::AfterMkdirp()
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
RaisinTen authored and targos committed Oct 23, 2021
1 parent 5a588ff commit 814126c
Showing 1 changed file with 11 additions and 16 deletions.
27 changes: 11 additions & 16 deletions src/node_file.cc
Original file line number Diff line number Diff line change
Expand Up @@ -714,24 +714,19 @@ void FromNamespacedPath(std::string* path) {
void AfterMkdirp(uv_fs_t* req) {
FSReqBase* req_wrap = FSReqBase::from_req(req);
FSReqAfterScope after(req_wrap, req);

MaybeLocal<Value> path;
Local<Value> error;

if (after.Proceed()) {
if (!req_wrap->continuation_data()->first_path().empty()) {
std::string first_path(req_wrap->continuation_data()->first_path());
FromNamespacedPath(&first_path);
path = StringBytes::Encode(req_wrap->env()->isolate(), first_path.c_str(),
req_wrap->encoding(),
&error);
if (path.IsEmpty())
req_wrap->Reject(error);
else
req_wrap->Resolve(path.ToLocalChecked());
} else {
req_wrap->Resolve(Undefined(req_wrap->env()->isolate()));
std::string first_path(req_wrap->continuation_data()->first_path());
if (first_path.empty())
return req_wrap->Resolve(Undefined(req_wrap->env()->isolate()));
FromNamespacedPath(&first_path);
Local<Value> path;
Local<Value> error;
if (!StringBytes::Encode(req_wrap->env()->isolate(), first_path.c_str(),
req_wrap->encoding(),
&error).ToLocal(&path)) {
return req_wrap->Reject(error);
}
return req_wrap->Resolve(path);
}
}

Expand Down

0 comments on commit 814126c

Please sign in to comment.