@@ -298,6 +298,21 @@ static void GetCallSites(const FunctionCallbackInfo<Value>& args) {
298298 args.GetReturnValue ().Set (callsites);
299299}
300300
301+ static void IsStringOneByte (const FunctionCallbackInfo<Value>& args) {
302+ CHECK_EQ (args.Length (), 1 );
303+ CHECK (args[0 ]->IsString ());
304+ bool is_one_byte = args[0 ].As <String>()->IsOneByte ();
305+ args.GetReturnValue ().Set (is_one_byte);
306+ }
307+
308+ static bool FastIsStringOneByte (Local<Value> receiver,
309+ const Local<Value> target) {
310+ CHECK (target->IsString ());
311+ return target.As <String>()->IsOneByte ();
312+ }
313+
314+ CFunction fast_is_string_one_byte_ (CFunction::Make(FastIsStringOneByte));
315+
301316static void IsInsideNodeModules (const FunctionCallbackInfo<Value>& args) {
302317 Isolate* isolate = args.GetIsolate ();
303318 CHECK_EQ (args.Length (), 2 );
@@ -356,6 +371,9 @@ void RegisterExternalReferences(ExternalReferenceRegistry* registry) {
356371 registry->Register (fast_guess_handle_type_.GetTypeInfo ());
357372 registry->Register (ParseEnv);
358373 registry->Register (IsInsideNodeModules);
374+ registry->Register (IsStringOneByte);
375+ registry->Register (FastIsStringOneByte);
376+ registry->Register (fast_is_string_one_byte_.GetTypeInfo ());
359377}
360378
361379void Initialize (Local<Object> target,
@@ -471,6 +489,11 @@ void Initialize(Local<Object> target,
471489 " guessHandleType" ,
472490 GuessHandleType,
473491 &fast_guess_handle_type_);
492+ SetFastMethodNoSideEffect (context,
493+ target,
494+ " isStringOneByte" ,
495+ IsStringOneByte,
496+ &fast_is_string_one_byte_);
474497}
475498
476499} // namespace util
0 commit comments