Skip to content

Commit

Permalink
short circuit decodeImplicitModules and decodeVirtualPairComponent wi…
Browse files Browse the repository at this point in the history
…th filename includes check
  • Loading branch information
raycohen committed Sep 26, 2023
1 parent 5f7fa32 commit 2d08d0c
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions packages/core/src/virtual-content.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,10 @@ export function virtualPairComponent(hbsModule: string, jsModule: string | null)
function decodeVirtualPairComponent(
filename: string
): { relativeHBSModule: string; relativeJSModule: string | null; debugName: string } | null {
// Performance: avoid paying regex exec cost unless needed
if (!filename.includes(pairComponentMarker)) {
return null;
}
let match = pairComponentPattern.exec(filename);
if (!match) {
return null;
Expand Down Expand Up @@ -186,6 +190,10 @@ const implicitModulesPattern = /(?<filename>.*)[\\/]-embroider-implicit-(?<test>
export function decodeImplicitModules(
filename: string
): { type: 'implicit-modules' | 'implicit-test-modules'; fromFile: string } | undefined {
// Performance: avoid paying regex exec cost unless needed
if (!filename.includes('-embroider-implicit-')) {
return;
}
let m = implicitModulesPattern.exec(filename);
if (m) {
return {
Expand Down

0 comments on commit 2d08d0c

Please sign in to comment.