mirror of
https://github.com/zebrajr/node.git
synced 2026-01-15 12:15:26 +00:00
src: prefer OnScopeLeave over shared_ptr<void>
They do the same thing, but OnScopeLeave avoids an extra heap allocation and is more explicit about what it does. PR-URL: https://github.com/nodejs/node/pull/32247 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Matheus Marchini <mat@mmarchini.me>
This commit is contained in:
@@ -832,7 +832,7 @@ static void InternalModuleReadJSON(const FunctionCallbackInfo<Value>& args) {
|
||||
return;
|
||||
}
|
||||
|
||||
std::shared_ptr<void> defer_close(nullptr, [fd, loop] (...) {
|
||||
auto defer_close = OnScopeLeave([fd, loop]() {
|
||||
uv_fs_t close_req;
|
||||
CHECK_EQ(0, uv_fs_close(loop, &close_req, fd, nullptr));
|
||||
uv_fs_req_cleanup(&close_req);
|
||||
|
||||
@@ -202,7 +202,7 @@ MaybeLocal<String> NativeModuleLoader::LoadBuiltinModuleSource(Isolate* isolate,
|
||||
CHECK_GE(req.result, 0);
|
||||
uv_fs_req_cleanup(&req);
|
||||
|
||||
std::shared_ptr<void> defer_close(nullptr, [file](...) {
|
||||
auto defer_close = OnScopeLeave([file]() {
|
||||
uv_fs_t close_req;
|
||||
CHECK_EQ(0, uv_fs_close(nullptr, &close_req, file, nullptr));
|
||||
uv_fs_req_cleanup(&close_req);
|
||||
|
||||
Reference in New Issue
Block a user