Skip to content

Commit dca7c96

Browse files
committed
rewrite byId in CubeDictionary to Map<string, Cube>
1 parent 6230419 commit dca7c96

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,24 +8,24 @@ export interface Cube {
88
}
99

1010
export class CubeDictionary implements TranspilerCubeResolver, CompilerInterface {
11-
public byId: Record<string, Cube>;
11+
public byId: Map<string, Cube>;
1212

1313
public constructor() {
14-
this.byId = {};
14+
this.byId = new Map<string, Cube>();
1515
}
1616

1717
public compile(cubes: Cube[], _errorReporter?: ErrorReporter): void {
18-
this.byId = {};
18+
this.byId = new Map<string, Cube>();
1919
for (const cube of cubes) {
20-
this.byId[cube.name] = cube;
20+
this.byId.set(cube.name, cube);
2121
}
2222
}
2323

24-
public resolveCube(name: string): boolean {
25-
return !!this.byId[name];
24+
public resolveCube(name: string): Cube | undefined {
25+
return this.byId.get(name);
2626
}
2727

2828
public free(): void {
29-
this.byId = {};
29+
this.byId = new Map<string, Cube>();
3030
}
3131
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -560,7 +560,7 @@ export class DataSchemaCompiler {
560560
}
561561

562562
private prepareTranspileSymbols() {
563-
const cubeNames: string[] = Object.keys(this.cubeDictionary.byId);
563+
const cubeNames: string[] = Array.from(this.cubeDictionary.byId.keys());
564564
// We need only cubes and all its member names for transpiling.
565565
// Cubes doesn't change during transpiling, but are changed during compilation phase,
566566
// so we can prepare them once for every phase.

packages/cubejs-schema-compiler/src/compiler/transpilers/transpiler.interface.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ export interface TranspilerInterface {
88
}
99

1010
export interface TranspilerSymbolResolver {
11-
resolveSymbol(cubeName, name): any;
12-
isCurrentCube(name): boolean;
11+
resolveSymbol(cubeName: string | null | undefined, name: string): any;
12+
isCurrentCube(name: string): boolean;
1313
}
1414

1515
export interface TranspilerCubeResolver {
16-
resolveCube(name): boolean;
16+
resolveCube(name: string): any;
1717
}
1818

1919
export type SymbolResolver = (name: string) => any;

0 commit comments

Comments
 (0)