Merge "logd: prune maintain per-id watermark (part deux)"
am: 390100305b

* commit '390100305b032d0d6bd42a1797c01b35c714d13f':
  logd: prune maintain per-id watermark (part deux)
diff --git a/logd/LogBuffer.cpp b/logd/LogBuffer.cpp
index cdf5d08..9e0d451 100644
--- a/logd/LogBuffer.cpp
+++ b/logd/LogBuffer.cpp
@@ -332,13 +332,21 @@
         }
     }
 
-    bool setLast = mLastSet[id] && (it == mLast[id]);
+    bool setLast[LOG_ID_MAX];
+    bool doSetLast = false;
+    log_id_for_each(i) {
+        doSetLast |= setLast[i] = mLastSet[i] && (it == mLast[i]);
+    }
     it = mLogElements.erase(it);
-    if (setLast) {
-        if (it == mLogElements.end()) { // unlikely
-            mLastSet[id] = false;
-        } else {
-            mLast[id] = it;
+    if (doSetLast) {
+        log_id_for_each(i) {
+            if (setLast[i]) {
+                if (it == mLogElements.end()) { // unlikely
+                    mLastSet[i] = false;
+                } else {
+                    mLast[i] = it;
+                }
+            }
         }
     }
     if (coalesce) {