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

Simplify & optimize style calculation #3498

Merged
merged 5 commits into from
Nov 1, 2016
Merged

Simplify & optimize style calculation #3498

merged 5 commits into from
Nov 1, 2016

Conversation

mourner
Copy link
Member

@mourner mourner commented Oct 31, 2016

A major cleanup of the style recalculation code. 50 less lines of code, much less confusion and also slightly improves performance. All commits are self-contained so review commit by commit.

One noteable architectural change is that globalProperties properties like zoomHistory, time and duration that were specific to transition implementation are moved out and live where they belong. So now globalProperties are always just {zoom}, although I didn't replace it with just zoom yet because @lucaswoj anticipates other global properties in future.

benchmark master 8127e17 simplify-calculate 55faf5f
frame-duration 6.9 ms, 0% > 16ms 6.4 ms, 0% > 16ms

👀 @lucaswoj @jfirebaugh

@mourner mourner added refactoring 🏗️ performance ⚡ Speed, stability, CPU usage, memory usage, or power usage labels Oct 31, 2016
@mourner mourner force-pushed the simplify-calculate branch from 55faf5f to 54de836 Compare November 1, 2016 14:48
@mourner
Copy link
Member Author

mourner commented Nov 1, 2016

Had to rebase to resolve a minor conflict with Flow PR, but made sure the tests pass on each commit so that they can be merged without squashing.

return this.interp(oldValue, value, t);
}

_calculateTargetValue(globalProperties, featureProperties) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why did you decide to factor this out into a separate method? What does target mean in this context?

Copy link
Member Author

Choose a reason for hiding this comment

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

This code earlier lived mostly in style_declaration wrapTransitionedCalculate here. What this method does is calculate the value the property is transitioning to, as opposed to calculate which returns the current value that is transitioning from the old value to the target one with time — please see calculate above.

);

t.end();
});
Copy link
Contributor

Choose a reason for hiding this comment

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

Why did you delete these tests?

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah. I see. 👇

Copy link
Member Author

Choose a reason for hiding this comment

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

I moved it into a new style_transition.test.js

Copy link
Contributor

@lucaswoj lucaswoj left a comment

Choose a reason for hiding this comment

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

A couple questions. This looks ready to go if you're satisfied with their answers. 👍

@mourner mourner merged commit 371240e into master Nov 1, 2016
@mourner mourner deleted the simplify-calculate branch November 1, 2016 15:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
performance ⚡ Speed, stability, CPU usage, memory usage, or power usage refactoring 🏗️
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants