From 4030eff3d60af6f18893a938fad9e0d78b29004e Mon Sep 17 00:00:00 2001 From: Darshan Sen Date: Sat, 9 Oct 2021 20:16:14 +0530 Subject: [PATCH] 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 PR-URL: https://github.com/nodejs/node/pull/40386 Reviewed-By: James M Snell Reviewed-By: Anna Henningsen --- src/node_file.cc | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/src/node_file.cc b/src/node_file.cc index 350e66b6e426b8..c7c73669a17ff7 100644 --- a/src/node_file.cc +++ b/src/node_file.cc @@ -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 path; - Local 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 path; + Local 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); } }