1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-06 12:41:29 +00:00

incompleteHosts is multiset, not list, so size() is constant-time

This commit is contained in:
dmiller
2024-02-26 18:29:10 +00:00
parent 630f2d27bc
commit f5634144c6
2 changed files with 2 additions and 20 deletions

View File

@@ -390,7 +390,7 @@ bool GroupScanStats::sendOK(struct timeval *when) const {
/* When there is only one target left, let the host congestion
stuff deal with it. */
if (USI->numIncompleteHostsLessThan(2)) {
if (USI->numIncompleteHosts() < 2) {
if (when)
*when = USI->now;
return true;
@@ -1114,28 +1114,11 @@ HostScanStats *UltraScanInfo::findHost(struct sockaddr_storage *ss) const {
return NULL;
}
/* Check if incompleteHosts list contains less than n elements. This function
is here to replace numIncompleteHosts() < n, which would have to walk
through the entire list. */
bool UltraScanInfo::numIncompleteHostsLessThan(unsigned int n) const {
std::multiset<HostScanStats *, HssPredicate>::const_iterator hostI;
unsigned int count;
count = 0;
hostI = incompleteHosts.begin();
while (count < n && hostI != incompleteHosts.end()) {
hostI++;
count++;
}
return count < n;
}
static bool pingprobe_is_better(const probespec *new_probe, int new_state,
const probespec *old_probe, int old_state);
/* Removes any hosts that have completed their scans from the incompleteHosts
list, and remove any hosts from completedHosts which have exceeded their
set, and remove any hosts from completedHosts which have exceeded their
lifetime. Returns the number of hosts removed. */
int UltraScanInfo::removeCompletedHosts() {
std::multiset<HostScanStats *, HssPredicate>::iterator hostI, nxt;

View File

@@ -598,7 +598,6 @@ public:
bool incompleteHostsEmpty() const {
return incompleteHosts.empty();
}
bool numIncompleteHostsLessThan(unsigned int n) const;
unsigned int numInitialHosts() const {
return numInitialTargets;