From f444c8e5ee4fcc25cdd260c6478de93dc56271a1 Mon Sep 17 00:00:00 2001 From: Mert Can Altin Date: Sun, 13 Jul 2025 14:35:36 +0300 Subject: [PATCH] buffer: cache Environment::GetCurrent to avoid repeated calls --- src/node_buffer.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/node_buffer.cc b/src/node_buffer.cc index c356a22bec23bf..2fff0488cd81cd 100644 --- a/src/node_buffer.cc +++ b/src/node_buffer.cc @@ -1061,8 +1061,9 @@ void IndexOfBuffer(const FunctionCallbackInfo& args) { enum encoding enc = static_cast(args[3].As()->Value()); - THROW_AND_RETURN_UNLESS_BUFFER(Environment::GetCurrent(args), args[0]); - THROW_AND_RETURN_UNLESS_BUFFER(Environment::GetCurrent(args), args[1]); + Environment* env = Environment::GetCurrent(args); + THROW_AND_RETURN_UNLESS_BUFFER(env, args[0]); + THROW_AND_RETURN_UNLESS_BUFFER(env, args[1]); ArrayBufferViewContents haystack_contents(args[0]); ArrayBufferViewContents needle_contents(args[1]); int64_t offset_i64 = args[2].As()->Value();