Skip to content

Commit

Permalink
Use regex for faster manifest/typedef detection (#976)
Browse files Browse the repository at this point in the history
  • Loading branch information
TwitchBronBron committed Dec 4, 2023
1 parent 64d651c commit 70c487e
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions src/ProgramBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -471,21 +471,22 @@ export class ProgramBuilder {
});
this.logger.trace('ProgramBuilder.loadAllFilesAST() files:', files);

const acceptableSourceExtensions = ['.bs', '.brs', '.xml'];
const typedefFiles = [] as FileObj[];
const sourceFiles = [] as FileObj[];
let manifestFile: FileObj | null = null;

for (const file of files) {
const srcLower = file.src.toLowerCase();
if (srcLower.endsWith('.d.bs')) {
typedefFiles.push(file);
} else if (acceptableSourceExtensions.includes(path.extname(srcLower))) {
// source files (.brs, .bs, .xml)
if (/(?<!\.d)\.(bs|brs|xml)$/i.test(file.dest)) {
sourceFiles.push(file);
} else {
if (file.dest.toLowerCase() === 'manifest') {
manifestFile = file;
}

// typedef files (.d.bs)
} else if (/\.d\.bs$/i.test(file.dest)) {
typedefFiles.push(file);

// manifest file
} else if (/^manifest$/i.test(file.dest)) {
manifestFile = file;
}
}

Expand Down

0 comments on commit 70c487e

Please sign in to comment.