Skip to content

Commit

Permalink
[Fixes #15001] Remove internal EmptyObject usage
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanpenner committed Mar 12, 2017
1 parent 5ff9fd5 commit 7f5190a
Show file tree
Hide file tree
Showing 19 changed files with 55 additions and 71 deletions.
8 changes: 4 additions & 4 deletions packages/container/lib/registry.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { dictionary, EmptyObject, assign, intern } from 'ember-utils';
import { dictionary, assign, intern } from 'ember-utils';
import { assert, deprecate } from 'ember-metal';
import Container from './container';

Expand Down Expand Up @@ -35,7 +35,7 @@ export default function Registry(options) {
this._factoryTypeInjections = dictionary(null);
this._factoryInjections = dictionary(null);

this._localLookupCache = new EmptyObject();
this._localLookupCache = Object.create(null);
this._normalizeCache = dictionary(null);
this._resolveCache = dictionary(null);
this._failCache = dictionary(null);
Expand Down Expand Up @@ -205,7 +205,7 @@ Registry.prototype = {

let normalizedName = this.normalize(fullName);

this._localLookupCache = new EmptyObject();
this._localLookupCache = Object.create(null);

delete this.registrations[normalizedName];
delete this._resolveCache[normalizedName];
Expand Down Expand Up @@ -811,7 +811,7 @@ function expandLocalLookup(registry, normalizedName, normalizedSource) {
let normalizedNameCache = cache[normalizedName];

if (!normalizedNameCache) {
normalizedNameCache = cache[normalizedName] = new EmptyObject();
normalizedNameCache = cache[normalizedName] = Object.create(null);
}

let cached = normalizedNameCache[normalizedSource];
Expand Down
6 changes: 3 additions & 3 deletions packages/ember-application/lib/system/engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
@module ember
@submodule ember-application
*/
import { canInvoke, EmptyObject } from 'ember-utils';
import { canInvoke } from 'ember-utils';
import {
Namespace,
RegistryProxyMixin,
Expand Down Expand Up @@ -168,8 +168,8 @@ const Engine = Namespace.extend(RegistryProxyMixin, {
});

Engine.reopenClass({
initializers: new EmptyObject(),
instanceInitializers: new EmptyObject(),
initializers: Object.create(null),
instanceInitializers: Object.create(null),

/**
The goal of initializers should be to register dependencies and injections.
Expand Down
3 changes: 1 addition & 2 deletions packages/ember-glimmer/lib/components/text_field.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@
@module ember
@submodule ember-views
*/
import { EmptyObject } from 'ember-utils';
import { computed } from 'ember-metal';
import { environment } from 'ember-environment';
import Component from '../component';
import layout from '../templates/empty';
import { TextSupport } from 'ember-views';

let inputTypeTestElement;
const inputTypes = new EmptyObject();
const inputTypes = Object.create(null);
function canSetTypeOfInput(type) {
if (type in inputTypes) {
return inputTypes[type];
Expand Down
8 changes: 4 additions & 4 deletions packages/ember-glimmer/lib/utils/iterable.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { guidFor, EmptyObject } from 'ember-utils';
import { guidFor } from 'ember-utils';
import { get, tagForProperty, tagFor, isProxy } from 'ember-metal';
import {
objectAt,
Expand Down Expand Up @@ -84,7 +84,7 @@ class ArrayIterator {
this.length = array.length;
this.keyFor = keyFor;
this.position = 0;
this.seen = new EmptyObject();
this.seen = Object.create(null);
}

isEmpty() {
Expand Down Expand Up @@ -112,7 +112,7 @@ class EmberArrayIterator {
this.length = get(array, 'length');
this.keyFor = keyFor;
this.position = 0;
this.seen = new EmptyObject();
this.seen = Object.create(null);
}

isEmpty() {
Expand Down Expand Up @@ -140,7 +140,7 @@ class ObjectKeysIterator {
this.values = values;
this.keyFor = keyFor;
this.position = 0;
this.seen = new EmptyObject();
this.seen = Object.create(null);
}

isEmpty() {
Expand Down
7 changes: 3 additions & 4 deletions packages/ember-glimmer/lib/utils/process-args.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import {
assign,
symbol,
EmptyObject
symbol
} from 'ember-utils';
import {
CONSTANT_TAG
Expand Down Expand Up @@ -88,8 +87,8 @@ export class ComponentArgs {
let { namedArgs } = this;
let keys = namedArgs.keys;
let attrs = namedArgs.value();
let props = new EmptyObject();
let args = new EmptyObject();
let props = Object.create(null);
let args = Object.create(null);

props[ARGS] = args;

Expand Down
5 changes: 2 additions & 3 deletions packages/ember-glimmer/lib/utils/references.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import {
HAS_NATIVE_WEAKMAP,
symbol,
EmptyObject
symbol
} from 'ember-utils';
import {
get,
Expand Down Expand Up @@ -72,7 +71,7 @@ export class CachedReference extends EmberPathReference {
export class RootReference extends ConstReference {
constructor(value) {
super(value);
this.children = new EmptyObject();
this.children = Object.create(null);
}

get(propertyKey) {
Expand Down
4 changes: 2 additions & 2 deletions packages/ember-glimmer/lib/views/outlet.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
@module ember
@submodule ember-glimmer
*/
import { assign, EmptyObject } from 'ember-utils';
import { assign } from 'ember-utils';
import { DirtyableTag } from '@glimmer/reference';
import { environment } from 'ember-environment';
import { OWNER } from 'ember-utils';
Expand Down Expand Up @@ -56,7 +56,7 @@ class OrphanedOutletStateReference extends OutletStateReference {
return null;
}

let state = new EmptyObject();
let state = Object.create(null);
state[matched.render.outlet] = matched;
matched.wasUsed = true;
return { outlets: state };
Expand Down
3 changes: 1 addition & 2 deletions packages/ember-glimmer/tests/unit/layout-cache-test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { EmptyObject } from 'ember-utils';
import { RenderingTest, moduleFor } from '../utils/test-case';
import { CompiledBlock } from '@glimmer/runtime';
import { OWNER } from 'ember-utils';
Expand All @@ -19,7 +18,7 @@ class Counter {

reset() {
this.total = 0;
this.counts = new EmptyObject();
this.counts = Object.create(null);
}
}

Expand Down
5 changes: 2 additions & 3 deletions packages/ember-metal/lib/cache.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { EmptyObject } from 'ember-utils';
import { UNDEFINED } from './meta';

export default class Cache {
Expand Down Expand Up @@ -57,7 +56,7 @@ export default class Cache {

class DefaultStore {
constructor() {
this.data = new EmptyObject();
this.data = Object.create(null);
}

get(key) {
Expand All @@ -69,6 +68,6 @@ class DefaultStore {
}

clear() {
this.data = new EmptyObject();
this.data = Object.create(null);
}
}
5 changes: 2 additions & 3 deletions packages/ember-metal/lib/chains.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { EmptyObject } from 'ember-utils';
import { get } from './property_get';
import { meta as metaFor, peekMeta } from './meta';
import { watchKey, unwatchKey } from './watch_key';
Expand All @@ -23,7 +22,7 @@ class ChainWatchers {
// chain nodes that reference a key in this obj by key
// we only create ChainWatchers when we are going to add them
// so create this upfront
this.chains = new EmptyObject();
this.chains = Object.create(null);
}

add(key, node) {
Expand Down Expand Up @@ -231,7 +230,7 @@ class ChainNode {
let chains = this._chains;
let node;
if (chains === undefined) {
chains = this._chains = new EmptyObject();
chains = this._chains = Object.create(null);
} else {
node = chains[key];
}
Expand Down
12 changes: 6 additions & 6 deletions packages/ember-metal/lib/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
Map is mocked out to look like an Ember object, so you can do
`Ember.Map.create()` for symmetry with other Ember classes.
*/
import { EmptyObject, guidFor } from 'ember-utils';
import { guidFor } from 'ember-utils';

function missingFunction(fn) {
throw new TypeError(`${Object.prototype.toString.call(fn)} is not a function`);
Expand All @@ -31,10 +31,10 @@ function missingNew(name) {
}

function copyNull(obj) {
let output = new EmptyObject();
let output = Object.create(null);

for (let prop in obj) {
// hasOwnPropery is not needed because obj is new EmptyObject();
// hasOwnPropery is not needed because obj is Object.create(null);
output[prop] = obj[prop];
}

Expand Down Expand Up @@ -90,7 +90,7 @@ OrderedSet.prototype = {
@private
*/
clear() {
this.presenceSet = new EmptyObject();
this.presenceSet = Object.create(null);
this.list = [];
this.size = 0;
},
Expand Down Expand Up @@ -242,7 +242,7 @@ function Map() {
if (this instanceof Map) {
this._keys = OrderedSet.create();
this._keys._silenceRemoveDeprecation = true;
this._values = new EmptyObject();
this._values = Object.create(null);
this.size = 0;
} else {
missingNew('Map');
Expand Down Expand Up @@ -394,7 +394,7 @@ Map.prototype = {
*/
clear() {
this._keys.clear();
this._values = new EmptyObject();
this._values = Object.create(null);
this.size = 0;
},

Expand Down
9 changes: 4 additions & 5 deletions packages/ember-metal/lib/meta.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import {
HAS_NATIVE_WEAKMAP,
EmptyObject,
lookupDescriptor,
symbol
} from 'ember-utils';
Expand Down Expand Up @@ -202,7 +201,7 @@ export class Meta {
}

_getOrCreateOwnMap(key) {
return this[key] || (this[key] = new EmptyObject());
return this[key] || (this[key] = Object.create(null));
}

_getInherited(key) {
Expand Down Expand Up @@ -238,7 +237,7 @@ export class Meta {
let outerMap = this._getOrCreateOwnMap('_deps');
let innerMap = outerMap[subkey];
if (!innerMap) {
innerMap = outerMap[subkey] = new EmptyObject();
innerMap = outerMap[subkey] = Object.create(null);
}
innerMap[itemkey] = value;
}
Expand Down Expand Up @@ -277,7 +276,7 @@ export class Meta {

_forEachIn(key, subkey, fn) {
let pointer = this;
let seen = new EmptyObject();
let seen = Object.create(null);
let calls = [];
while (pointer !== undefined) {
let map = pointer[key];
Expand Down Expand Up @@ -368,7 +367,7 @@ function inheritedMap(name, Meta) {

Meta.prototype[`forEach${capitalized}`] = function(fn) {
let pointer = this;
let seen = new EmptyObject();
let seen = Object.create(null);
while (pointer !== undefined) {
let map = pointer[key];
if (map) {
Expand Down
5 changes: 2 additions & 3 deletions packages/ember-routing/lib/system/cache.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { EmptyObject } from 'ember-utils';
import { Object as EmberObject } from 'ember-runtime';

/**
Expand All @@ -10,7 +9,7 @@ import { Object as EmberObject } from 'ember-runtime';
*/
export default EmberObject.extend({
init() {
this.cache = new EmptyObject();
this.cache = Object.create(null);
},

has(bucketKey) {
Expand All @@ -21,7 +20,7 @@ export default EmberObject.extend({
let bucket = this.cache[bucketKey];

if (!bucket) {
bucket = this.cache[bucketKey] = new EmptyObject();
bucket = this.cache[bucketKey] = Object.create(null);
}

bucket[key] = value;
Expand Down
15 changes: 7 additions & 8 deletions packages/ember-routing/lib/system/router.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import {
EmptyObject,
assign,
guidFor,
dictionary,
Expand Down Expand Up @@ -144,11 +143,11 @@ const EmberRouter = EmberObject.extend(Evented, {
this.currentRouteName = null;
this.currentPath = null;

this._qpCache = new EmptyObject();
this._qpCache = Object.create(null);
this._resetQueuedQueryParameterChanges();
this._handledErrors = dictionary(null);
this._engineInstances = new EmptyObject();
this._engineInfoByRoute = new EmptyObject();
this._engineInstances = Object.create(null);
this._engineInfoByRoute = Object.create(null)
},

/*
Expand Down Expand Up @@ -571,7 +570,7 @@ const EmberRouter = EmberObject.extend(Evented, {
},

_getHandlerFunction() {
let seen = new EmptyObject();
let seen = Object.create(null);
let owner = getOwner(this);

return name => {
Expand Down Expand Up @@ -1024,7 +1023,7 @@ const EmberRouter = EmberObject.extend(Evented, {
let engineInstances = this._engineInstances;

if (!engineInstances[name]) {
engineInstances[name] = new EmptyObject();
engineInstances[name] = Object.create(null);
}

let engineInstance = engineInstances[name][instanceId];
Expand Down Expand Up @@ -1483,7 +1482,7 @@ function appendLiveRoute(liveRoutes, defaultParentState, renderOptions) {
let target;
let myState = {
render: renderOptions,
outlets: new EmptyObject(),
outlets: Object.create(null),
wasUsed: false
};
if (renderOptions.into) {
Expand Down Expand Up @@ -1528,7 +1527,7 @@ function appendOrphan(liveRoutes, into, myState) {
render: {
name: '__ember_orphans__'
},
outlets: new EmptyObject()
outlets: Object.create(null)
};
}
liveRoutes.outlets.__ember_orphans__.outlets[into] = myState;
Expand Down
Loading

0 comments on commit 7f5190a

Please sign in to comment.