Skip to content

Preparatory expression refactors - #5407

Merged
anandthakker merged 4 commits into
masterfrom
expressions-other-contexts
Oct 5, 2017
Merged

anandthakker merged 4 commits into
masterfrom
expressions-other-contexts

Conversation

@anandthakker

Copy link
Copy Markdown
Contributor

No description provided.

@anandthakker

Copy link
Copy Markdown
Contributor Author

@jfirebaugh couple of preparatory changes that I'd like to get merged to reduce need for invasive rebasing in #5253 and #5193

Comment thread src/style-spec/expression/index.js Outdated
expression = createExpression(expression, expectedType);
function createExpressionWithErrorHandling(expression: mixed, options: StyleExpressionOptions): StyleExpression {
expression = createExpression(expression, options);
const defaultValue = options.defaultValue === undefined ? null : options.defaultValue;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we have errorHandling: boolean as an option and then expose only createExpression()?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, we need to unify the two somehow for #5222 and #5370. I was trying to figure out a clean way to do it. Could we use an error return type by default, and push the try/catch up to StyleDeclaration#calculate? I avoided doing this in previous performance PRs because it would make the expression benchmarks not strictly comparable, but I'm 👍 on doing it in an independent PR.

Also, we should use Color ubiquitously so unwrap becomes unnecessary.

@jfirebaugh jfirebaugh Oct 5, 2017 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we use an error return type by default, and push the try/catch up to StyleDeclaration#calculate?

Hmm, nope, that regresses layout performance, presumably because constant "evaluation" is also wrapped in try/catch. https://bl.ocks.org/anonymous/raw/2b247bab7e59c3f83fa75ad8c7f2921d/

@anandthakker anandthakker Oct 5, 2017 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jfirebaugh could we just decide whether to do error handling based on the presence or absence of defaultValue?

Comment thread src/style-spec/expression/index.js Outdated
+properties: {[string]: any}
};

export type StyleExpressionContext = 'declaration' | 'filter';

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'declaration' → 'property'?

Comment thread src/style-spec/expression/index.js Outdated
expression = createExpression(expression, expectedType);
function createExpressionWithErrorHandling(expression: mixed, options: StyleExpressionOptions): StyleExpression {
expression = createExpression(expression, options);
const defaultValue = options.defaultValue === undefined ? null : options.defaultValue;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, we need to unify the two somehow for #5222 and #5370. I was trying to figure out a clean way to do it. Could we use an error return type by default, and push the try/catch up to StyleDeclaration#calculate? I avoided doing this in previous performance PRs because it would make the expression benchmarks not strictly comparable, but I'm 👍 on doing it in an independent PR.

Also, we should use Color ubiquitously so unwrap becomes unnecessary.

@anandthakker
anandthakker force-pushed the expressions-other-contexts branch from b79f9fc to 93d6857 Compare October 5, 2017 18:16
@anandthakker
anandthakker force-pushed the expressions-other-contexts branch from 93d6857 to 7923f77 Compare October 5, 2017 18:27
@anandthakker
anandthakker merged commit 2d359bb into master Oct 5, 2017
@anandthakker
anandthakker deleted the expressions-other-contexts branch October 5, 2017 18:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants