You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
perf: inline normalize/validate/encode and eliminate second URL parse
- Replace PurlComponent indirection with direct function calls in
constructor (12 property chain lookups eliminated) and stringify
(6 property chain lookups eliminated)
- Eliminate second new URL() allocation for auth detection by using
simple string checks for the authority section
These are the hottest paths in the parser — every parse and toString
call benefits.
* Convert PackageURL instance to canonical PURL string.
@@ -40,19 +48,19 @@ export function stringify(purl: PackageURL): string {
40
48
type?: string|undefined
41
49
version?: string|undefined
42
50
}=purl
43
-
/* c8 ignore next - Type encoder uses default PurlComponentEncoder, never returns null/undefined. */letpurlStr=`pkg:${(PurlComponent['type']?.['encode']asComponentEncoder)?.(type)??''}/`
/* c8 ignore next - Name encoder always returns string, never null/undefined. */purlStr=`${purlStr}${(PurlComponent['name']?.['encode']asComponentEncoder)?.(name)??''}`
55
+
purlStr=`${purlStr}${encodeName(name)}`
48
56
if(version){
49
-
/* c8 ignore next - Version encoder always returns string, never null/undefined. */purlStr=`${purlStr}@${(PurlComponent['version']?.['encode']asComponentEncoder)?.(version)??''}`
57
+
purlStr=`${purlStr}@${encodeVersion(version)}`
50
58
}
51
59
if(qualifiers){
52
-
/* c8 ignore next - Qualifiers encoder always returns string, never null/undefined. */purlStr=`${purlStr}?${(PurlComponent['qualifiers']?.['encode']asComponentEncoder)?.(qualifiers)??''}`
0 commit comments