Skip to content

Commit

Permalink
prefer Object.create(null) for vertex by name map
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanpenner committed Aug 18, 2014
1 parent d793d08 commit d5bd2b9
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions packages/ember-application/lib/system/dag.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ function visit(vertex, fn, visited, path) {
*/
function DAG() {
this.names = [];
this.vertices = {};
this.vertices = Object.create(null);
}

/**
* DAG Vertex
*
Expand All @@ -61,15 +63,10 @@ function Vertex(name) {
* @param {String} name The name of the vertex to add
*/
DAG.prototype.add = function(name) {
<<<<<<< HEAD
if (this.vertices.hasOwnProperty(name)) {
if (!name) { throw new Error("Can't add Vertex without name"); }
=======
if (!name) {
throw new Error("Can't add Vertex without name");
}
if (this.vertices[name] !== undefined) {
>>>>>>> f30005d... asdf
return this.vertices[name];
}
var vertex = new Vertex(name);
Expand Down

0 comments on commit d5bd2b9

Please sign in to comment.