Skip to content

Commit 3bef521

Browse files
fix address comments
1 parent de98105 commit 3bef521

File tree

2 files changed

+191
-191
lines changed

2 files changed

+191
-191
lines changed

src/sdam/topology.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -959,16 +959,16 @@ function processWaitQueue(topology: Topology) {
959959
continue;
960960
}
961961

962+
let selectedServer;
962963
if (selectedDescriptions.length === 0) {
963964
topology[kWaitQueue].push(waitQueueMember);
964965
continue;
965-
}
966-
967-
let selectedServer;
968-
if (selectedDescriptions.length === 1) {
966+
} else if (selectedDescriptions.length === 1) {
969967
selectedServer = topology.s.servers.get(selectedDescriptions[0].address);
970968
} else {
971-
const descriptions = shuffle(selectedDescriptions, 2);
969+
// don't shuffle the array if there are only two elements
970+
const descriptions =
971+
selectedDescriptions.length === 2 ? selectedDescriptions : shuffle(selectedDescriptions, 2);
972972
const server1 = topology.s.servers.get(descriptions[0].address);
973973
const server2 = topology.s.servers.get(descriptions[1].address);
974974

0 commit comments

Comments
 (0)