Skip to content

Commit 1bfde15

Browse files
committed
Add a TODO comment ... insertion sort in a loop is awkward
1 parent 206d6d3 commit 1bfde15

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/app/clusters/network-commissioning/network-commissioning.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,9 @@ CHIP_ERROR ThreadScanResponseToTLV::LoadResponses(Platform::ScopedMemoryBuffer<T
267267
scanResponseArrayLength++;
268268
}
269269
scanResponseArray[scanResponseArrayLength - 1] = scanResponse;
270+
271+
// TODO: this is a sort (insertion sort even, so O(n^2)) in a O(n) loop,
272+
/// maybe we should find something better than a O(n^3) to preserve the highest rssi only
270273
Sorting::InsertionSort(scanResponseArray.Get(), scanResponseArrayLength,
271274
[](const ThreadScanResponse & a, const ThreadScanResponse & b) -> bool { return a.rssi > b.rssi; });
272275
}

0 commit comments

Comments
 (0)