Skip to content

Commit abf19bf

Browse files
martinpittmvollmer
authored andcommitted
FIXUP: Avoid O(n²) in sorting rows
Set/use a `data-known` flag instead. #22884 (comment)
1 parent 93bc118 commit abf19bf

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

pkg/networkmanager/network-interface.jsx

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -921,16 +921,10 @@ export const NetworkInterfacePage = ({
921921
const isActive = activeSSID && r.props["data-ssid"] === activeSSID;
922922
if (isActive) {
923923
activeRows.push(r);
924+
} else if (r.props["data-known"]) {
925+
knownRows.push(r);
924926
} else {
925-
// Check if known by looking for Connection in the AP data
926-
// Search in all APs (not just filtered ones) to find by MAC
927-
const mac = r.props.key;
928-
const ap = accessPoints.find(ap => ap.HwAddress === mac);
929-
if (ap?.Connection) {
930-
knownRows.push(r);
931-
} else {
932-
unknownRows.push(r);
933-
}
927+
unknownRows.push(r);
934928
}
935929
});
936930

@@ -1059,7 +1053,7 @@ export const NetworkInterfacePage = ({
10591053
{ title: cockpit.format_bits_per_sec(ap.MaxBitrate * 1000) },
10601054
{ title: actionColumn },
10611055
],
1062-
props: { key: ap.HwAddress, "data-ssid": ap.Ssid }
1056+
props: { key: ap.HwAddress, "data-ssid": ap.Ssid, "data-known": !!ap.Connection }
10631057
};
10641058
});
10651059

0 commit comments

Comments
 (0)