diff --git a/src/env.cc b/src/env.cc index feb648a2b66aaf..39e0d7309ef92f 100644 --- a/src/env.cc +++ b/src/env.cc @@ -567,30 +567,15 @@ void Environment::RegisterHandleCleanups() { }); }; - RegisterHandleCleanup( - reinterpret_cast(timer_handle()), - close_and_finish, - nullptr); - RegisterHandleCleanup( - reinterpret_cast(immediate_check_handle()), - close_and_finish, - nullptr); - RegisterHandleCleanup( - reinterpret_cast(immediate_idle_handle()), - close_and_finish, - nullptr); - RegisterHandleCleanup( - reinterpret_cast(&idle_prepare_handle_), - close_and_finish, - nullptr); - RegisterHandleCleanup( - reinterpret_cast(&idle_check_handle_), - close_and_finish, - nullptr); - RegisterHandleCleanup( - reinterpret_cast(&task_queues_async_), - close_and_finish, - nullptr); + auto register_handle = [&](uv_handle_t* handle) { + RegisterHandleCleanup(handle, close_and_finish, nullptr); + }; + register_handle(reinterpret_cast(timer_handle())); + register_handle(reinterpret_cast(immediate_check_handle())); + register_handle(reinterpret_cast(immediate_idle_handle())); + register_handle(reinterpret_cast(&idle_prepare_handle_)); + register_handle(reinterpret_cast(&idle_check_handle_)); + register_handle(reinterpret_cast(&task_queues_async_)); } void Environment::CleanupHandles() {