Skip to content

Commit

Permalink
cache firstSegment
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanpenner committed Jul 24, 2014
1 parent b9d2369 commit 9eae607
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion packages/ember-handlebars/lib/ext.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,20 @@ var slice = [].slice, originalTemplate = EmberHandlebars.template;
@param path {String}
@param data {Hash}
*/

import Cache from 'ember-metal/cache';

var FIRST_SEGMENT_CACHE = new Cache(1000, function(path){
return path.split('.', 1)[0];
});

function normalizePath(root, path, data) {
var keywords = (data && data.keywords) || {};
var keyword, isKeyword;

// Get the first segment of the path. For example, if the
// path is "foo.bar.baz", returns "foo".
keyword = path.split('.', 1)[0];
keyword = FIRST_SEGMENT_CACHE.get(path);

// Test to see if the first path is a keyword that has been
// passed along in the view's data hash. If so, we will treat
Expand Down

0 comments on commit 9eae607

Please sign in to comment.