Skip to content

Commit 426f85c

Browse files
Quick perf mitigation: precompute NamespaceURL.href
It’s a little bit surprising that the biggest perf hit on this branch comes from `NamespaceURL`! This commit mitigates the biggest hit I see in profiling. After this I’m going to do a brief timeboxed spike into using branded types rather than runtime to clearly distinguish between the inherent pair of nullable strings (namespace URI, prefix). If another commit doesn’t follow this one on the PR, safe to assume I didn’t ultimately pursue that direction (at least for now).
1 parent 4f52e47 commit 426f85c

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

packages/xforms-engine/src/lib/names/NamespaceURL.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,14 @@ export class NamespaceURL extends URL {
3131
return null;
3232
}
3333

34-
return new this(namespaceURI);
34+
return new this(String(namespaceURI));
3535
}
3636

37-
private constructor(namespaceURI: NamespaceURL | string) {
38-
super(namespaceURI);
37+
override readonly href: string;
38+
39+
private constructor(href: string) {
40+
super(href);
41+
42+
this.href = href;
3943
}
4044
}

0 commit comments

Comments
 (0)