@@ -806,15 +806,16 @@ int64_t IndexOfOffset(size_t length,
806806}
807807
808808void IndexOfString (const FunctionCallbackInfo<Value>& args) {
809+ Environment* env = Environment::GetCurrent (args);
810+ Isolate* isolate = env->isolate ();
811+
809812 CHECK (args[1 ]->IsString ());
810813 CHECK (args[2 ]->IsNumber ());
811814 CHECK (args[4 ]->IsBoolean ());
812815
813- enum encoding enc = ParseEncoding (args.GetIsolate (),
814- args[3 ],
815- UTF8);
816+ enum encoding enc = ParseEncoding (isolate, args[3 ], UTF8);
816817
817- THROW_AND_RETURN_UNLESS_BUFFER (Environment::GetCurrent (args) , args[0 ]);
818+ THROW_AND_RETURN_UNLESS_BUFFER (env , args[0 ]);
818819 SPREAD_BUFFER_ARG (args[0 ], ts_obj);
819820
820821 Local<String> needle = args[1 ].As <String>();
@@ -826,8 +827,7 @@ void IndexOfString(const FunctionCallbackInfo<Value>& args) {
826827 const size_t haystack_length = (enc == UCS2) ?
827828 ts_obj_length &~ 1 : ts_obj_length; // NOLINT(whitespace/operators)
828829
829- const size_t needle_length =
830- StringBytes::Size (args.GetIsolate (), needle, enc);
830+ const size_t needle_length = StringBytes::Size (isolate, needle, enc);
831831
832832 int64_t opt_offset = IndexOfOffset (haystack_length,
833833 offset_i64,
@@ -857,7 +857,7 @@ void IndexOfString(const FunctionCallbackInfo<Value>& args) {
857857 size_t result = haystack_length;
858858
859859 if (enc == UCS2) {
860- String::Value needle_value (args. GetIsolate () , needle);
860+ String::Value needle_value (isolate , needle);
861861 if (*needle_value == nullptr )
862862 return args.GetReturnValue ().Set (-1 );
863863
@@ -867,7 +867,7 @@ void IndexOfString(const FunctionCallbackInfo<Value>& args) {
867867
868868 if (IsBigEndian ()) {
869869 StringBytes::InlineDecoder decoder;
870- decoder.Decode (Environment::GetCurrent (args) , needle, args[3 ], UCS2);
870+ decoder.Decode (env , needle, args[3 ], UCS2);
871871 const uint16_t * decoded_string =
872872 reinterpret_cast <const uint16_t *>(decoder.out ());
873873
@@ -890,7 +890,7 @@ void IndexOfString(const FunctionCallbackInfo<Value>& args) {
890890 }
891891 result *= 2 ;
892892 } else if (enc == UTF8) {
893- String::Utf8Value needle_value (args. GetIsolate () , needle);
893+ String::Utf8Value needle_value (isolate , needle);
894894 if (*needle_value == nullptr )
895895 return args.GetReturnValue ().Set (-1 );
896896
@@ -906,7 +906,7 @@ void IndexOfString(const FunctionCallbackInfo<Value>& args) {
906906 return args.GetReturnValue ().Set (-1 );
907907 }
908908 needle->WriteOneByte (
909- needle_data, 0 , needle_length, String::NO_NULL_TERMINATION);
909+ isolate, needle_data, 0 , needle_length, String::NO_NULL_TERMINATION);
910910
911911 result = SearchString (reinterpret_cast <const uint8_t *>(haystack),
912912 haystack_length,
@@ -1057,18 +1057,20 @@ void Swap64(const FunctionCallbackInfo<Value>& args) {
10571057// Used in TextEncoder.prototype.encode.
10581058static void EncodeUtf8String (const FunctionCallbackInfo<Value>& args) {
10591059 Environment* env = Environment::GetCurrent (args);
1060+ Isolate* isolate = env->isolate ();
10601061 CHECK_GE (args.Length (), 1 );
10611062 CHECK (args[0 ]->IsString ());
10621063
10631064 Local<String> str = args[0 ].As <String>();
10641065 size_t length = str->Utf8Length ();
10651066 char * data = node::UncheckedMalloc (length);
1066- str->WriteUtf8 (data,
1067- -1 , // We are certain that `data` is sufficiently large
1067+ str->WriteUtf8 (isolate,
1068+ data,
1069+ -1 , // We are certain that `data` is sufficiently large
10681070 nullptr ,
10691071 String::NO_NULL_TERMINATION | String::REPLACE_INVALID_UTF8);
1070- auto array_buf = ArrayBuffer::New (env-> isolate (), data, length,
1071- ArrayBufferCreationMode::kInternalized );
1072+ auto array_buf = ArrayBuffer::New (
1073+ isolate, data, length, ArrayBufferCreationMode::kInternalized );
10721074 auto array = Uint8Array::New (array_buf, 0 , length);
10731075 args.GetReturnValue ().Set (array);
10741076}
0 commit comments