Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preparatory expression refactors #5407

Merged
merged 4 commits into from Oct 5, 2017
Merged

Conversation

anandthakker
Copy link
Contributor

No description provided.

@anandthakker
Copy link
Contributor Author

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

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
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
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.

Copy link
Contributor

@jfirebaugh jfirebaugh Oct 5, 2017

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/

Copy link
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?

@@ -24,19 +24,31 @@ export type Feature = {
+properties: {[string]: any}
};

export type StyleExpressionContext = 'declaration' | 'filter';
Copy link
Contributor

Choose a reason for hiding this comment

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

'declaration''property'?

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
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 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.

None yet

2 participants