Skip to content

Commit

Permalink
Added tiny optimization
Browse files Browse the repository at this point in the history
Change-Id: I596613115c5aa16a915610d2b2844c3237ad399f
  • Loading branch information
spt29 committed Oct 22, 2024
1 parent 346f9ca commit 7edd1db
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion packages/livestatus/src/TableLog.cc
Original file line number Diff line number Diff line change
Expand Up @@ -216,9 +216,20 @@ void for_each_log_entry(
while (it_entries != entries->begin()) {
--it_entries;
const auto &entry = *it_entries->second;
if (entry.time() < since || !process_log_entry(entry)) {
if (entry.time() < since) {
// The current log line is older than requested, so stop
// processing all log entries and log files.
return;
}

// NOTE: The test() call below is just an optimization,
// Logfile::getEntriesFor() can return more than it is being
// asked for. :-/
if (log_filter.restrictions.log_entry_classes.test(
static_cast<size_t>(entry.log_class())) &&
!process_log_entry(entry)) {
return; // The callback has requested to stop processing.
}
}
if (it_logs == log_files.begin()) {
break; // this was the oldest one
Expand Down

0 comments on commit 7edd1db

Please sign in to comment.