Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 20118eec authored by Tom Cherry's avatar Tom Cherry
Browse files

logd: rename mOldest -> oldest_

I added mOldest recently before mentally committing to have new code
follow the Google C++ style guide.

Test: build
Change-Id: I6d5bab5833e14ac3808862598a2a60989d805e18
parent 5a3db391
Loading
Loading
Loading
Loading
+6 −6
Original line number Diff line number Diff line
@@ -129,14 +129,14 @@ LogBuffer::~LogBuffer() {

LogBufferElementCollection::iterator LogBuffer::GetOldest(log_id_t log_id) {
    auto it = mLogElements.begin();
    if (mOldest[log_id]) {
        it = *mOldest[log_id];
    if (oldest_[log_id]) {
        it = *oldest_[log_id];
    }
    while (it != mLogElements.end() && (*it)->getLogId() != log_id) {
        it++;
    }
    if (it != mLogElements.end()) {
        mOldest[log_id] = it;
        oldest_[log_id] = it;
    }
    return it;
}
@@ -460,7 +460,7 @@ LogBufferElementCollection::iterator LogBuffer::erase(

    bool setLast[LOG_ID_MAX];
    bool doSetLast = false;
    log_id_for_each(i) { doSetLast |= setLast[i] = mOldest[i] && it == *mOldest[i]; }
    log_id_for_each(i) { doSetLast |= setLast[i] = oldest_[i] && it == *oldest_[i]; }
#ifdef DEBUG_CHECK_FOR_STALE_ENTRIES
    LogBufferElementCollection::iterator bad = it;
    int key = ((id == LOG_ID_EVENTS) || (id == LOG_ID_SECURITY))
@@ -472,9 +472,9 @@ LogBufferElementCollection::iterator LogBuffer::erase(
        log_id_for_each(i) {
            if (setLast[i]) {
                if (__predict_false(it == mLogElements.end())) {
                    mOldest[i] = std::nullopt;
                    oldest_[i] = std::nullopt;
                } else {
                    mOldest[i] = it;  // Store the next iterator even if it does not correspond to
                    oldest_[i] = it;  // Store the next iterator even if it does not correspond to
                                      // the same log_id, as a starting point for GetOldest().
                }
            }
+4 −3
Original line number Diff line number Diff line
@@ -80,9 +80,6 @@ class LogBuffer {

    LogStatistics stats;

    // Keeps track of the iterator to the oldest log message of a given log type, as an
    // optimization when pruning logs.  Use GetOldest() to retrieve.
    std::optional<LogBufferElementCollection::iterator> mOldest[LOG_ID_MAX];
    // watermark of any worst/chatty uid processing
    typedef std::unordered_map<uid_t, LogBufferElementCollection::iterator>
        LogBufferIteratorMap;
@@ -167,4 +164,8 @@ class LogBuffer {

    LogTags* tags_;
    PruneList* prune_;

    // Keeps track of the iterator to the oldest log message of a given log type, as an
    // optimization when pruning logs.  Use GetOldest() to retrieve.
    std::optional<LogBufferElementCollection::iterator> oldest_[LOG_ID_MAX];
};