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 <darshan.sen@postman.com>

PR-URL: #40386
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
  • Loading branch information
RaisinTen authored and BethGriggs committed Nov 23, 2021
1 parent bf88328 commit 4030eff
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 4030eff

Please sign in to comment.