From 6c8b6bcbdee2d0c557787e5e65c8590a4463704f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Mu=C3=B1oz?= Date: Tue, 9 Feb 2016 14:57:01 -0500 Subject: [PATCH] [BUGFIX beta] Avoid allocating a binding map in meta when possible --- packages/ember-metal/lib/meta.js | 2 +- .../ember-runtime/tests/system/object/create_test.js | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/packages/ember-metal/lib/meta.js b/packages/ember-metal/lib/meta.js index cf42b88f6bc..e5f6a9bfd85 100644 --- a/packages/ember-metal/lib/meta.js +++ b/packages/ember-metal/lib/meta.js @@ -126,7 +126,7 @@ function inheritedMap(name, Meta) { }; Meta.prototype['clear' + capitalized] = function() { - this[key] = new EmptyObject(); + this[key] = undefined; }; Meta.prototype['deleteFrom' + capitalized] = function(subkey) { diff --git a/packages/ember-runtime/tests/system/object/create_test.js b/packages/ember-runtime/tests/system/object/create_test.js index 966e0a3f8e3..e2f22c0cba7 100644 --- a/packages/ember-runtime/tests/system/object/create_test.js +++ b/packages/ember-runtime/tests/system/object/create_test.js @@ -1,7 +1,8 @@ import Ember from 'ember-metal/core'; import isEnabled from 'ember-metal/features'; -import {computed} from 'ember-metal/computed'; -import {Mixin, observer} from 'ember-metal/mixin'; +import { meta } from 'ember-metal/meta'; +import { computed } from 'ember-metal/computed'; +import { Mixin, observer } from 'ember-metal/mixin'; import EmberObject from 'ember-runtime/system/object'; var moduleOptions, originalLookup; @@ -144,3 +145,9 @@ QUnit.test('EmberObject.create can take null as a parameter', function() { var o = EmberObject.create(null); deepEqual(EmberObject.create(), o); }); + +QUnit.test('EmberObject.create avoids allocating a binding map when not necessary', function() { + let o = EmberObject.create(); + let m = meta(o); + ok(!m.peekBindings(), 'A binding map is not allocated'); +});