pool: fix hostlist.toArray.

This commit is contained in:
Christopher Jeffrey 2016-12-21 15:49:46 -08:00
parent 1a4984d533
commit 35fba9f3ae
No known key found for this signature in database
GPG Key ID: 8962AB9DE6666BBD

View File

@ -2778,23 +2778,14 @@ HostList.prototype.evictUsed = function evictUsed(bucket) {
*/
HostList.prototype.toArray = function toArray() {
var keys = Object.keys(this.map);
var out = [];
var i, j, keys, key, bucket, entry;
var i, key, entry;
for (i = 0; i < this.fresh.length; i++) {
bucket = this.fresh[i];
keys = bucket.keys();
for (j = 0; j < keys.length; j++) {
key = keys[j];
entry = bucket.get(key);
out.push(entry.addr);
}
}
for (i = 0; i < this.used.length; i++) {
bucket = this.used[i];
for (entry = bucket.head; entry; entry = entry.next)
out.push(entry.addr);
for (i = 0; i < keys.length; i++) {
key = keys[i];
entry = this.map[key];
out.push(entry);
}
assert.equal(out.length, this.size());