Skip to content

Commit

Permalink
Some optimizations to setEdge
Browse files Browse the repository at this point in the history
  • Loading branch information
cpettitt-linkedin committed Jul 14, 2015
1 parent 8faec95 commit 9685135
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions lib/graph.js
Original file line number Diff line number Diff line change
Expand Up @@ -352,18 +352,19 @@ Graph.prototype.setPath = function(vs, value) {
*/
Graph.prototype.setEdge = function() {
var v, w, name, value,
valueSpecified = false;
valueSpecified = false,
arg0 = arguments[0];

if (_.isPlainObject(arguments[0])) {
v = arguments[0].v;
w = arguments[0].w;
name = arguments[0].name;
if (typeof arg0 === "object" && arg0 !== null && "v" in arg0) {
v = arg0.v;
w = arg0.w;
name = arg0.name;
if (arguments.length === 2) {
value = arguments[1];
valueSpecified = true;
}
} else {
v = arguments[0];
v = arg0;
w = arguments[1];
name = arguments[3];
if (arguments.length > 2) {
Expand Down Expand Up @@ -475,7 +476,7 @@ Graph.prototype.nodeEdges = function(v, w) {
};

function incrementOrInitEntry(map, k) {
if (_.has(map, k)) {
if (map[k]) {
map[k]++;
} else {
map[k] = 1;
Expand Down

0 comments on commit 9685135

Please sign in to comment.