Skip to content

Commit 8615ea6

Browse files
mertcanaltinaduh95
authored andcommitted
buffer: cache Environment::GetCurrent to avoid repeated calls
PR-URL: #59043 Reviewed-By: James M Snell <[email protected]> Reviewed-By: theanarkh <[email protected]> Reviewed-By: Dario Piotrowicz <[email protected]> Reviewed-By: Juan José Arboleda <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Yagiz Nizipli <[email protected]>
1 parent 3a9aca9 commit 8615ea6

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
@@ -1046,8 +1046,9 @@ void IndexOfBuffer(const FunctionCallbackInfo<Value>& args) {
10461046

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

1049-
THROW_AND_RETURN_UNLESS_BUFFER(Environment::GetCurrent(args), args[0]);
1050-
THROW_AND_RETURN_UNLESS_BUFFER(Environment::GetCurrent(args), args[1]);
1049+
Environment* env = Environment::GetCurrent(args);
1050+
THROW_AND_RETURN_UNLESS_BUFFER(env, args[0]);
1051+
THROW_AND_RETURN_UNLESS_BUFFER(env, args[1]);
10511052
ArrayBufferViewContents<char> haystack_contents(args[0]);
10521053
ArrayBufferViewContents<char> needle_contents(args[1]);
10531054
int64_t offset_i64 = args[2].As<Integer>()->Value();

0 commit comments

Comments
 (0)