Skip to content

Commit

Permalink
Merge pull request #58 from stefanpenner/cache
Browse files Browse the repository at this point in the history
add normalization caching.
  • Loading branch information
stefanpenner committed Jul 18, 2014
2 parents 6f43191 + 65da62e commit a8e90ab
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 5 deletions.
2 changes: 1 addition & 1 deletion dist/ember-resolver-spade.js

Large diffs are not rendered by default.

16 changes: 15 additions & 1 deletion dist/ember-resolver.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ define("ember/resolver",
* output. The loader's _moduleEntries is consulted so that classes can be
* resolved directly via the module loader, without needing a manual
* `import`.
* 2) is able provide injections to classes that implement `extend`
* 2) is able to provide injections to classes that implement `extend`
* (as is typical with Ember).
*/

Expand All @@ -44,6 +44,13 @@ define("ember/resolver",
};
}

function makeDictionary() {
var cache = Object.create(null);
cache['_dict'] = null;
delete cache['_dict'];
return cache;
}

var underscore = Ember.String.underscore;
var classify = Ember.String.classify;
var get = Ember.get;
Expand Down Expand Up @@ -137,7 +144,14 @@ define("ember/resolver",
shouldWrapInClassFactory: function(module, parsedName){
return false;
},
init: function() {
this._super();
this._normalizeCache = makeDictionary();
},
normalize: function(fullName) {
return this._normalizeCache[fullName] || (this._normalizeCache = this._normalize(fullName));
},
_normalize: function(fullName) {
// replace `.` with `/` in order to make nested controllers work in the following cases
// 1. `needs: ['posts/post']`
// 2. `{{render "posts/post"}}`
Expand Down
2 changes: 1 addition & 1 deletion dist/ember-resolver.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 15 additions & 1 deletion dist/ember-resolver.prod.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ define("ember/resolver",
* output. The loader's _moduleEntries is consulted so that classes can be
* resolved directly via the module loader, without needing a manual
* `import`.
* 2) is able provide injections to classes that implement `extend`
* 2) is able to provide injections to classes that implement `extend`
* (as is typical with Ember).
*/

Expand All @@ -44,6 +44,13 @@ define("ember/resolver",
};
}

function makeDictionary() {
var cache = Object.create(null);
cache['_dict'] = null;
delete cache['_dict'];
return cache;
}

var underscore = Ember.String.underscore;
var classify = Ember.String.classify;
var get = Ember.get;
Expand Down Expand Up @@ -137,7 +144,14 @@ define("ember/resolver",
shouldWrapInClassFactory: function(module, parsedName){
return false;
},
init: function() {
this._super();
this._normalizeCache = makeDictionary();
},
normalize: function(fullName) {
return this._normalizeCache[fullName] || (this._normalizeCache = this._normalize(fullName));
},
_normalize: function(fullName) {
// replace `.` with `/` in order to make nested controllers work in the following cases
// 1. `needs: ['posts/post']`
// 2. `{{render "posts/post"}}`
Expand Down
16 changes: 15 additions & 1 deletion dist/modules/ember-resolver.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ define("ember/resolver",
* output. The loader's _moduleEntries is consulted so that classes can be
* resolved directly via the module loader, without needing a manual
* `import`.
* 2) is able provide injections to classes that implement `extend`
* 2) is able to provide injections to classes that implement `extend`
* (as is typical with Ember).
*/

Expand All @@ -34,6 +34,13 @@ define("ember/resolver",
};
}

function makeDictionary() {
var cache = Object.create(null);
cache['_dict'] = null;
delete cache['_dict'];
return cache;
}

var underscore = Ember.String.underscore;
var classify = Ember.String.classify;
var get = Ember.get;
Expand Down Expand Up @@ -127,7 +134,14 @@ define("ember/resolver",
shouldWrapInClassFactory: function(module, parsedName){
return false;
},
init: function() {
this._super();
this._normalizeCache = makeDictionary();
},
normalize: function(fullName) {
return this._normalizeCache[fullName] || (this._normalizeCache = this._normalize(fullName));
},
_normalize: function(fullName) {
// replace `.` with `/` in order to make nested controllers work in the following cases
// 1. `needs: ['posts/post']`
// 2. `{{render "posts/post"}}`
Expand Down
14 changes: 14 additions & 0 deletions packages/ember-resolver/lib/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,13 @@ define("ember/resolver",
};
}

function makeDictionary() {
var cache = Object.create(null);
cache['_dict'] = null;
delete cache['_dict'];
return cache;
}

var underscore = Ember.String.underscore;
var classify = Ember.String.classify;
var get = Ember.get;
Expand Down Expand Up @@ -126,7 +133,14 @@ define("ember/resolver",
shouldWrapInClassFactory: function(module, parsedName){
return false;
},
init: function() {
this._super();
this._normalizeCache = makeDictionary();
},
normalize: function(fullName) {
return this._normalizeCache[fullName] || (this._normalizeCache = this._normalize(fullName));
},
_normalize: function(fullName) {
// replace `.` with `/` in order to make nested controllers work in the following cases
// 1. `needs: ['posts/post']`
// 2. `{{render "posts/post"}}`
Expand Down

0 comments on commit a8e90ab

Please sign in to comment.