MediaMetrics: Misc fixes

Remove unneeded headers from MediaMetricsItem.
Optimize map writes with emplace_hint.

Test: atest mediametrics_tests
Bug: 149850236
Change-Id: Ice6fddb8402a5ccbf1df6e6e02fa4aae4c1b42d5
gugelfrei
Andy Hung 4 years ago
parent 369ad27456
commit 7d391087f8

@ -25,6 +25,7 @@
#include <set>
#include <binder/Parcel.h>
#include <cutils/properties.h>
#include <utils/Errors.h>
#include <utils/Log.h>
#include <utils/SortedVector.h>

@ -27,12 +27,8 @@
#include <variant>
#include <binder/Parcel.h>
#include <cutils/properties.h>
#include <utils/Errors.h>
#include <utils/KeyedVector.h>
#include <utils/RefBase.h>
#include <utils/StrongPointer.h>
#include <utils/Timers.h>
#include <utils/Timers.h> // nsecs_t
namespace android {

@ -138,7 +138,7 @@ private:
if (timeSequence.empty() // no elements
|| property.back() == AMEDIAMETRICS_PROP_SUFFIX_CHAR_DUPLICATES_ALLOWED
|| timeSequence.rbegin()->second != el) { // value changed
timeSequence.emplace(time, std::move(el));
timeSequence.emplace_hint(timeSequence.end(), time, std::move(el));
if (timeSequence.size() > kTimeSequenceMaxElements) {
ALOGV("%s: restricting maximum elements (discarding oldest) for %s",

@ -94,8 +94,8 @@ public:
std::lock_guard lock(mLock);
(void)gc(garbage);
mLog.emplace(time, item);
mItemMap[key].emplace(time, item);
mLog.emplace_hint(mLog.end(), time, item);
mItemMap[key].emplace_hint(mItemMap[key].end(), time, item);
return NO_ERROR; // no errors for now.
}

Loading…
Cancel
Save