| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1046,9 +1046,11 @@ class URL { | |||
| 1046 | 1046 | url = `${url}`; | |
| 1047 | 1047 | ||
| 1048 | 1048 | if (base !== undefined) { | |
| 1049 | - return bindingUrl.canParseWithBase(url, `${base}`); | ||
| 1049 | + return bindingUrl.canParse(url, `${base}`); | ||
| 1050 | 1050 | } | |
| 1051 | 1051 | ||
| 1052 | + // It is important to differentiate the canParse call statements | ||
| 1053 | + // since they resolve into different v8 fast api overloads. | ||
| 1052 | 1054 | return bindingUrl.canParse(url); | |
| 1053 | 1055 | } | |
| 1054 | 1056 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -170,17 +170,15 @@ bool BindingData::FastCanParse(Local<Value> receiver, | |||
| 170 | 170 | return ada::can_parse(std::string_view(input.data, input.length)); | |
| 171 | 171 | } | |
| 172 | 172 | ||
| 173 | - CFunction BindingData::fast_can_parse_(CFunction::Make(FastCanParse)); | ||
| 174 | - | ||
| 175 | 173 | bool BindingData::FastCanParseWithBase(Local<Value> receiver, | |
| 176 | 174 | const FastOneByteString& input, | |
| 177 | 175 | const FastOneByteString& base) { | |
| 178 | 176 | auto base_view = std::string_view(base.data, base.length); | |
| 179 | 177 | return ada::can_parse(std::string_view(input.data, input.length), &base_view); | |
| 180 | 178 | } | |
| 181 | 179 | ||
| 182 | - CFunction BindingData::fast_can_parse_with_base_( | ||
| 183 | - CFunction::Make(FastCanParseWithBase)); | ||
| 180 | + CFunction BindingData::fast_can_parse_methods_[] = { | ||
| 181 | + CFunction::Make(FastCanParse), CFunction::Make(FastCanParseWithBase)}; | ||
| 184 | 182 | ||
| 185 | 183 | void BindingData::Format(const FunctionCallbackInfo<Value>& args) { | |
| 186 | 184 | CHECK_GT(args.Length(), 4); | |
@@ -361,12 +359,7 @@ void BindingData::CreatePerIsolateProperties(IsolateData* isolate_data, | |||
| 361 | 359 | SetMethod(isolate, target, "parse", Parse); | |
| 362 | 360 | SetMethod(isolate, target, "update", Update); | |
| 363 | 361 | SetFastMethodNoSideEffect( | |
| 364 | - isolate, target, "canParse", CanParse, &fast_can_parse_); | ||
| 365 | - SetFastMethodNoSideEffect(isolate, | ||
| 366 | - target, | ||
| 367 | - "canParseWithBase", | ||
| 368 | - CanParse, | ||
| 369 | - &fast_can_parse_with_base_); | ||
| 362 | + isolate, target, "canParse", CanParse, {fast_can_parse_methods_, 2}); | ||
| 370 | 363 | } | |
| 371 | 364 | ||
| 372 | 365 | void BindingData::CreatePerContextProperties(Local<Object> target, | |
@@ -387,9 +380,11 @@ void BindingData::RegisterExternalReferences( | |||
| 387 | 380 | registry->Register(Update); | |
| 388 | 381 | registry->Register(CanParse); | |
| 389 | 382 | registry->Register(FastCanParse); | |
| 390 | - registry->Register(fast_can_parse_.GetTypeInfo()); | ||
| 391 | 383 | registry->Register(FastCanParseWithBase); | |
| 392 | - registry->Register(fast_can_parse_with_base_.GetTypeInfo()); | ||
| 384 | + | ||
| 385 | + for (const CFunction& method : fast_can_parse_methods_) { | ||
| 386 | + registry->Register(method.GetTypeInfo()); | ||
| 387 | + } | ||
| 393 | 388 | } | |
| 394 | 389 | ||
| 395 | 390 | std::string FromFilePath(const std::string_view file_path) { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -75,8 +75,7 @@ class BindingData : public SnapshotableObject { | |||
| 75 | 75 | void UpdateComponents(const ada::url_components& components, | |
| 76 | 76 | const ada::scheme::type type); | |
| 77 | 77 | ||
| 78 | - static v8::CFunction fast_can_parse_; | ||
| 79 | - static v8::CFunction fast_can_parse_with_base_; | ||
| 78 | + static v8::CFunction fast_can_parse_methods_[]; | ||
| 80 | 79 | }; | |
| 81 | 80 | ||
| 82 | 81 | std::string FromFilePath(const std::string_view file_path); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -6,7 +6,6 @@ declare function InternalBinding(binding: 'url'): { | |||
| 6 | 6 | domainToASCII(input: string): string; | |
| 7 | 7 | domainToUnicode(input: string): string; | |
| 8 | 8 | canParse(input: string): boolean; | |
| 9 | - canParseWithBase(input: string, base: string): boolean; | ||
| 10 | 9 | format(input: string, fragment?: boolean, unicode?: boolean, search?: boolean, auth?: boolean): string; | |
| 11 | 10 | parse(input: string, base?: string): string | false; | |
| 12 | 11 | update(input: string, actionType: typeof urlUpdateActions, value: string): string | false; | |
| Back | FazBrowse Home | New Git URL |
0 commit comments