Skip to content

Commit 175bbd3

Browse files
committed
use toCompileFilesMap instead of array search
1 parent 9c873d7 commit 175bbd3

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

packages/cubejs-schema-compiler/src/compiler/DataSchemaCompiler.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,11 @@ export class DataSchemaCompiler {
225225
? files.filter(f => this.filesToCompile.includes(f.fileName))
226226
: files;
227227

228+
const toCompileFilesMap = toCompile.reduce((acc, f) => {
229+
acc[f.fileName] = f;
230+
return acc;
231+
}, {} as Record<string, FileContent>);
232+
228233
const errorsReport = new ErrorReporter(null, [], this.errorReportOptions);
229234
this.errorsReporter = errorsReport;
230235

@@ -399,7 +404,7 @@ export class DataSchemaCompiler {
399404
errorsReport,
400405
compiledFiles,
401406
[],
402-
[],
407+
{},
403408
{ doSyntaxCheck: true }
404409
);
405410
exports[foundFile.fileName] = exports[foundFile.fileName] || {};
@@ -420,7 +425,7 @@ export class DataSchemaCompiler {
420425
asyncModules = [];
421426
transpiledFiles = await transpile(stage);
422427

423-
const res = this.compileCubeFiles(cubes, contexts, compiledFiles, asyncModules, compilers, transpiledFiles, toCompile, errorsReport);
428+
const res = this.compileCubeFiles(cubes, contexts, compiledFiles, asyncModules, compilers, transpiledFiles, toCompileFilesMap, errorsReport);
424429
compilePhaseTimer.end();
425430
return res;
426431
};
@@ -661,7 +666,7 @@ export class DataSchemaCompiler {
661666
asyncModules: CallableFunction[],
662667
compilers: CompileCubeFilesCompilers,
663668
transpiledFiles: FileContent[],
664-
toCompile: FileContent[],
669+
toCompileFilesMap: Record<string, FileContent>,
665670
errorsReport: ErrorReporter
666671
) {
667672
transpiledFiles
@@ -671,7 +676,7 @@ export class DataSchemaCompiler {
671676
errorsReport,
672677
compiledFiles,
673678
asyncModules,
674-
toCompile
679+
toCompileFilesMap
675680
);
676681
});
677682
await asyncModules.reduce((a: Promise<void>, b: CallableFunction) => a.then(() => b()), Promise.resolve());
@@ -688,7 +693,7 @@ export class DataSchemaCompiler {
688693
errorsReport: ErrorReporter,
689694
compiledFiles: Record<string, boolean>,
690695
asyncModules: CallableFunction[],
691-
toCompile: FileContent[],
696+
toCompileFilesMap: Record<string, FileContent>,
692697
{ doSyntaxCheck } = { doSyntaxCheck: false }
693698
) {
694699
if (compiledFiles[file.fileName]) {
@@ -717,7 +722,7 @@ export class DataSchemaCompiler {
717722
this.pythonContext!
718723
);
719724
if (transpiledFile) {
720-
const originalFile = toCompile.find(f => f.fileName === file.fileName);
725+
const originalFile = toCompileFilesMap[file.fileName];
721726
originalFile!.content = transpiledFile.content;
722727
originalFile!.convertedToJs = true;
723728

0 commit comments

Comments
 (0)