Skip to content

Commit f281272

Browse files
mertcanaltinaduh95
authored andcommitted
buffer: cache Environment::GetCurrent to avoid repeated calls
PR-URL: #59043 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: theanarkh <theratliter@gmail.com> Reviewed-By: Dario Piotrowicz <dario.piotrowicz@gmail.com> Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
1 parent fe0195f commit f281272

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/node_buffer.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1061,8 +1061,9 @@ void IndexOfBuffer(const FunctionCallbackInfo<Value>& args) {
10611061

10621062
enum encoding enc = static_cast<enum encoding>(args[3].As<Int32>()->Value());
10631063

1064-
THROW_AND_RETURN_UNLESS_BUFFER(Environment::GetCurrent(args), args[0]);
1065-
THROW_AND_RETURN_UNLESS_BUFFER(Environment::GetCurrent(args), args[1]);
1064+
Environment* env = Environment::GetCurrent(args);
1065+
THROW_AND_RETURN_UNLESS_BUFFER(env, args[0]);
1066+
THROW_AND_RETURN_UNLESS_BUFFER(env, args[1]);
10661067
ArrayBufferViewContents<char> haystack_contents(args[0]);
10671068
ArrayBufferViewContents<char> needle_contents(args[1]);
10681069
int64_t offset_i64 = args[2].As<Integer>()->Value();

0 commit comments

Comments
 (0)