Skip to content

Commit 33a9955

Browse files
committed
attempt to optimize transpile of regular fields
+ perf tracking them
1 parent 87ec103 commit 33a9955

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

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

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -218,14 +218,26 @@ export class YamlCompiler {
218218
} else if (typeof obj === 'string') {
219219
let code = obj;
220220

221+
if (obj === '') {
222+
return t.nullLiteral();
223+
}
224+
225+
if (code.match(PY_TEMPLATE_SYNTAX)) {
226+
if (!nonStringFields.has(propertyPath[propertyPath.length - 1])) {
227+
code = `f"${this.escapeDoubleQuotes(obj)}"`;
228+
}
229+
230+
const parsePythonAndTranspileToJsTimer225 = perfTracker.start('parsePythonAndTranspileToJs call 225');
231+
const ast = this.parsePythonAndTranspileToJs(code, errorsReport);
232+
parsePythonAndTranspileToJsTimer225.end();
233+
return this.extractProgramBodyIfNeeded(ast);
234+
}
235+
221236
if (!nonStringFields.has(propertyPath[propertyPath.length - 1])) {
222-
code = `f"${this.escapeDoubleQuotes(obj)}"`;
237+
return t.templateLiteral([t.templateElement({ raw: code, cooked: code })], []);
223238
}
224239

225-
const parsePythonAndTranspileToJsTimer225 = perfTracker.start('parsePythonAndTranspileToJs call 225');
226-
const ast = this.parsePythonAndTranspileToJs(code, errorsReport);
227-
parsePythonAndTranspileToJsTimer225.end();
228-
return this.extractProgramBodyIfNeeded(ast);
240+
return t.identifier(code);
229241
} else if (typeof obj === 'boolean') {
230242
return t.booleanLiteral(obj);
231243
} else if (typeof obj === 'number') {

0 commit comments

Comments
 (0)