Skip to content
This repository has been archived by the owner on Mar 20, 2021. It is now read-only.

Performance optimations #389

Merged
merged 22 commits into from
Oct 16, 2014
Merged

Performance optimations #389

merged 22 commits into from
Oct 16, 2014

Conversation

kpdecker
Copy link
Contributor

A whole slew of macro and micro optimizations. These are generally non breaking but there are a few changes that may break some workflows.

  1. Users building with lumbar who desire the forms feature must include the thorax-form mixin
  2. The helper:$name event has been removed. Users should bind to the helper event and check the name parameter that they wish to examine.
  3. _.uniqueId no longer uses global variables for tracking state. Instead callers must call _resetIdCounter when wishing to modify that behavior.
  4. context no longer clones the model attributes so callers need to take care to not modify the returned value.

Provides a slight optimization on hot paths, but generally is a better practice for performance.
Avoid looping over calls that can be done in shot and utilize closers rather than binds.
Avoid cloning context when otherwise unnecessary.
Avoid arguments deoptimization cases.
Avoid repeated parsing operations and other potential performance issues.
Allows us to avoid global variables and causes an approximately 6x increase in the performance of this method.
Since data rendering is now default in handlebars and the errors will reference data and also occur early in the dev process, the overhead both for wire size and runtime exec of this sanity check does not seem worthwhile.
Increases the overall render performance on newer runtimes due to avoiding a copy of the view/current context on execution.

This has the side effect of `context` now returning a non-cloned object. Callers should take care to not modify the returned object.
This allows lumbar consumers to conditionally include this behavior. Longer term we will want to look at per-view options that let us conditionally include the form handling behavior (or make a definitive we do not support call)
@@ -213,7 +213,8 @@ Thorax.CollectionView = Thorax.View.extend({
itemView = model;
model = false;
} else {
index = index || collection.indexOf(model) || 0;
index = index != null ? index : (collection.indexOf(model) || 0);
Copy link
Contributor

Choose a reason for hiding this comment

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

What's the difference here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

micro opt: Avoids indexOf lookup for index === 0 case. Likely fast but felt like a why not avoid the call sort of case.

kpdecker added a commit that referenced this pull request Oct 16, 2014
@kpdecker kpdecker merged commit 9e7eea9 into master Oct 16, 2014
@kpdecker kpdecker deleted the performance-optimations branch October 16, 2014 01:28
@kpdecker
Copy link
Contributor Author

Released in 3.0.0-beta.4

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants