logd: remove LogFindWorst
LogStatistics relies on LogBuffer's lock for thread safety, but that
will be cleaned up in future CLs. It won't be possible to return a
'LogFindWorst' object that references internal LogStatistics pointers
in a thread safe way, so we remove this and provide a more simple
interface.
This also removes unnecessary allocations; std::array of 2 or 32
entries is small enough to allocate on the stack.
Test: logging unit tests
Change-Id: I38bfcba5b08c640ffd3af5c078bc716688f6edf8
diff --git a/logd/LogBuffer.cpp b/logd/LogBuffer.cpp
index 2cb0c5e..ad391e5 100644
--- a/logd/LogBuffer.cpp
+++ b/logd/LogBuffer.cpp
@@ -663,19 +663,14 @@
// Calculate threshold as 12.5% of available storage
size_t threshold = log_buffer_size(id) / 8;
- if ((id == LOG_ID_EVENTS) || (id == LOG_ID_SECURITY)) {
- stats.sortTags(AID_ROOT, (pid_t)0, 2, id)
- .findWorst(worst, worst_sizes, second_worst_sizes,
- threshold);
+ if (id == LOG_ID_EVENTS || id == LOG_ID_SECURITY) {
+ stats.WorstTwoTags(threshold, &worst, &worst_sizes, &second_worst_sizes);
// per-pid filter for AID_SYSTEM sources is too complex
} else {
- stats.sort(AID_ROOT, (pid_t)0, 2, id)
- .findWorst(worst, worst_sizes, second_worst_sizes,
- threshold);
+ stats.WorstTwoUids(id, threshold, &worst, &worst_sizes, &second_worst_sizes);
- if ((worst == AID_SYSTEM) && prune_->worstPidOfSystemEnabled()) {
- stats.sortPids(worst, (pid_t)0, 2, id)
- .findWorst(worstPid, worst_sizes, second_worst_sizes);
+ if (worst == AID_SYSTEM && prune_->worstPidOfSystemEnabled()) {
+ stats.WorstTwoSystemPids(id, worst_sizes, &worstPid, &second_worst_sizes);
}
}
}