diff --git a/map/map.js b/map/map.js index 2183c44480d..6f1f9eb8f44 100644 --- a/map/map.js +++ b/map/map.js @@ -103,7 +103,7 @@ steal('can/util', 'can/util/bind','./bubble.js', 'can/construct', 'can/util/batc return [attr]; } // Split key on '.' - return can.isArray(attr) ? attr : ("" + attr) + return typeof attr === "object" ? attr : ("" + attr) .split("."); }, /** @@ -336,7 +336,6 @@ steal('can/util', 'can/util/bind','./bubble.js', 'can/construct', 'can/util/batc return this._attrs(attr, val); // If we are getting a value. } else if (arguments.length === 1) { - // Let people know we are reading. can.__reading(this, attr); return this._get(attr); } else { @@ -390,6 +389,7 @@ steal('can/util', 'can/util/bind','./bubble.js', 'can/construct', 'can/util/batc }, // Reads a property from the `object`. _get: function (attr) { + var value; // Handles the case of a key having a `.` in its name @@ -510,7 +510,7 @@ steal('can/util', 'can/util/bind','./bubble.js', 'can/construct', 'can/util/batc } // Add property directly for easy writing. // Check if its on the `prototype` so we don't overwrite methods like `attrs`. - if (! typeof this.constructor.prototype[prop] === 'function' && !this._computedBindings[prop] ) { + if ( typeof this.constructor.prototype[prop] !== 'function' && !this._computedBindings[prop] ) { this[prop] = val; } }, diff --git a/map/map_test.js b/map/map_test.js index a7b0aac89ee..787c1ac5ef0 100644 --- a/map/map_test.js +++ b/map/map_test.js @@ -70,8 +70,8 @@ steal("can/map", "can/compute", "can/test", "can/list", function(){ }); state.removeAttr("key.with.dots"); state2.removeAttr("key.with.someValue"); - deepEqual(can.Map.keys(state), ["productType"], "one property"); - deepEqual(can.Map.keys(state2), ["key.with.dots", "key"], "two properties"); + deepEqual( can.Map.keys(state), ["productType"], "one property"); + deepEqual( can.Map.keys(state2), ["key.with.dots", "key"], "two properties"); deepEqual( can.Map.keys( state2.key["with"] ) , [], "zero properties"); }); diff --git a/map/test.html b/map/test.html index 16ff9b68e4c..d28c2be9969 100644 --- a/map/test.html +++ b/map/test.html @@ -27,7 +27,7 @@

can.dev.logLevel = 3; QUnit.start(); }); - },300); + },400); diff --git a/view/scope/scope.js b/view/scope/scope.js index e6b0896e036..7d7cd2f13cf 100644 --- a/view/scope/scope.js +++ b/view/scope/scope.js @@ -141,6 +141,8 @@ steal( rootReads = data.reads; computeData.scope = data.scope; computeData.initialValue = data.value; + computeData.reads = data.reads; + computeData.root = rootObserve; return data.value; } }) diff --git a/view/stache/mustache_core.js b/view/stache/mustache_core.js index e23feaeb592..f3392d6d6ff 100644 --- a/view/stache/mustache_core.js +++ b/view/stache/mustache_core.js @@ -240,6 +240,12 @@ steal("can/util", compute = computeData.compute; initialValue = computeData.initialValue; + if(computeData.reads && computeData.reads.length === 1 && computeData.root instanceof can.Map) { + console.log("fast") + //can.compute(computeData.root, computeData.reads[0]) + } + + // Set name to be the compute if the compute reads observables, // or the value of the value of the compute if no observables are found. if(computeData.compute.hasDependencies) { @@ -309,6 +315,7 @@ steal("can/util", return function(){ return name(); }; + } // Just return name as the value else { @@ -396,6 +403,7 @@ steal("can/util", return function branchRenderer(scope, options, truthyRenderer, falseyRenderer){ // TODO: What happens if same mode/expresion, but different sub-sections? // Check the scope's cache if the evaluator already exists for performance. + //console.log("here!"); var evaluator = scope.__cache[fullExpression]; if(!evaluator) { evaluator = scope.__cache[fullExpression] = makeEvaluator( scope, options, mode, exprData, truthyRenderer, falseyRenderer, true); diff --git a/view/stache/visual_benchmark.html b/view/stache/visual_benchmark.html index 264625c3ffd..28278d74bfd 100644 --- a/view/stache/visual_benchmark.html +++ b/view/stache/visual_benchmark.html @@ -85,8 +85,9 @@ } }); - for(var i =0; i < 100; i++) { + for(var i =0; i < 1; i++) { var box = new Box({ number: i }); + box.tick(); boxes.push( box ); } @@ -126,7 +127,7 @@ if (loopCount % 20 === 0) { $('#timing').text('Performed ' + loopCount + ' iterations in ' + totalTime + ' ms (average ' + (totalTime / loopCount).toFixed(2) + ' ms per loop).'); } - if(loopCount < 1000) { + if(loopCount < 0) { timeout = setTimeout(function(){ benchmarkLoop(fn); },1);