Permalink
Browse files

Optimization for counting keys in an object.

  • Loading branch information...
1 parent 9ceb12a commit 19829ee50f24a0cec089d3b3d1c6bd979914e315 Sean Fitzgerald committed Aug 8, 2012
Showing with 1 addition and 3 deletions.
  1. +1 −3 lib/consistent_hashing.js
View
4 lib/consistent_hashing.js
@@ -93,9 +93,7 @@ ConsistentHashing.prototype.getNodePosition = function(hash) {
ConsistentHashing.prototype.getRingLength = function() {
- var i = 0;
- for (var key in this.ring) { i++ }
- return i;
+ return Object.keys(this.ring).length;
};

0 comments on commit 19829ee

Please sign in to comment.