@@ -806,15 +806,16 @@ int64_t IndexOfOffset(size_t length,
806
806
}
807
807
808
808
void IndexOfString (const FunctionCallbackInfo<Value>& args) {
809
+ Environment* env = Environment::GetCurrent (args);
810
+ Isolate* isolate = env->isolate ();
811
+
809
812
CHECK (args[1 ]->IsString ());
810
813
CHECK (args[2 ]->IsNumber ());
811
814
CHECK (args[4 ]->IsBoolean ());
812
815
813
- enum encoding enc = ParseEncoding (args.GetIsolate (),
814
- args[3 ],
815
- UTF8);
816
+ enum encoding enc = ParseEncoding (isolate, args[3 ], UTF8);
816
817
817
- THROW_AND_RETURN_UNLESS_BUFFER (Environment::GetCurrent (args) , args[0 ]);
818
+ THROW_AND_RETURN_UNLESS_BUFFER (env , args[0 ]);
818
819
SPREAD_BUFFER_ARG (args[0 ], ts_obj);
819
820
820
821
Local<String> needle = args[1 ].As <String>();
@@ -826,8 +827,7 @@ void IndexOfString(const FunctionCallbackInfo<Value>& args) {
826
827
const size_t haystack_length = (enc == UCS2) ?
827
828
ts_obj_length &~ 1 : ts_obj_length; // NOLINT(whitespace/operators)
828
829
829
- const size_t needle_length =
830
- StringBytes::Size (args.GetIsolate (), needle, enc);
830
+ const size_t needle_length = StringBytes::Size (isolate, needle, enc);
831
831
832
832
int64_t opt_offset = IndexOfOffset (haystack_length,
833
833
offset_i64,
@@ -857,7 +857,7 @@ void IndexOfString(const FunctionCallbackInfo<Value>& args) {
857
857
size_t result = haystack_length;
858
858
859
859
if (enc == UCS2) {
860
- String::Value needle_value (args. GetIsolate () , needle);
860
+ String::Value needle_value (isolate , needle);
861
861
if (*needle_value == nullptr )
862
862
return args.GetReturnValue ().Set (-1 );
863
863
@@ -867,7 +867,7 @@ void IndexOfString(const FunctionCallbackInfo<Value>& args) {
867
867
868
868
if (IsBigEndian ()) {
869
869
StringBytes::InlineDecoder decoder;
870
- decoder.Decode (Environment::GetCurrent (args) , needle, args[3 ], UCS2);
870
+ decoder.Decode (env , needle, args[3 ], UCS2);
871
871
const uint16_t * decoded_string =
872
872
reinterpret_cast <const uint16_t *>(decoder.out ());
873
873
@@ -890,7 +890,7 @@ void IndexOfString(const FunctionCallbackInfo<Value>& args) {
890
890
}
891
891
result *= 2 ;
892
892
} else if (enc == UTF8) {
893
- String::Utf8Value needle_value (args. GetIsolate () , needle);
893
+ String::Utf8Value needle_value (isolate , needle);
894
894
if (*needle_value == nullptr )
895
895
return args.GetReturnValue ().Set (-1 );
896
896
@@ -906,7 +906,7 @@ void IndexOfString(const FunctionCallbackInfo<Value>& args) {
906
906
return args.GetReturnValue ().Set (-1 );
907
907
}
908
908
needle->WriteOneByte (
909
- needle_data, 0 , needle_length, String::NO_NULL_TERMINATION);
909
+ isolate, needle_data, 0 , needle_length, String::NO_NULL_TERMINATION);
910
910
911
911
result = SearchString (reinterpret_cast <const uint8_t *>(haystack),
912
912
haystack_length,
@@ -1057,18 +1057,20 @@ void Swap64(const FunctionCallbackInfo<Value>& args) {
1057
1057
// Used in TextEncoder.prototype.encode.
1058
1058
static void EncodeUtf8String (const FunctionCallbackInfo<Value>& args) {
1059
1059
Environment* env = Environment::GetCurrent (args);
1060
+ Isolate* isolate = env->isolate ();
1060
1061
CHECK_GE (args.Length (), 1 );
1061
1062
CHECK (args[0 ]->IsString ());
1062
1063
1063
1064
Local<String> str = args[0 ].As <String>();
1064
1065
size_t length = str->Utf8Length ();
1065
1066
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
1068
1070
nullptr ,
1069
1071
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 );
1072
1074
auto array = Uint8Array::New (array_buf, 0 , length);
1073
1075
args.GetReturnValue ().Set (array);
1074
1076
}
0 commit comments