Optimize incidentd memory usage
1. Remove dependency of libprotobuf-cpp-lite, saves .so mmap ~200KB
2. Don't use auto except iterator for readability.
Bug: 74254200
Test: adb shell dumpsys meminfo `pid incidentd`
Change-Id: If6198521c3b80929d6ea3f7ed466b5195991ccfd
diff --git a/cmds/incidentd/src/Reporter.cpp b/cmds/incidentd/src/Reporter.cpp
index 12764f8..fc8a6db 100644
--- a/cmds/incidentd/src/Reporter.cpp
+++ b/cmds/incidentd/src/Reporter.cpp
@@ -89,11 +89,11 @@
IncidentMetadata::SectionStats* ReportRequestSet::sectionStats(int id) {
if (mSectionStats.find(id) == mSectionStats.end()) {
- auto stats = mMetadata.add_sections();
- stats->set_id(id);
+ IncidentMetadata::SectionStats stats;
+ stats.set_id(id);
mSectionStats[id] = stats;
}
- return mSectionStats[id];
+ return &mSectionStats[id];
}
// ================================================================================
@@ -182,7 +182,7 @@
}
// Execute - go get the data and write it into the file descriptors.
- auto stats = batch.sectionStats(id);
+ IncidentMetadata::SectionStats* stats = batch.sectionStats(id);
int64_t startTime = uptimeMillis();
err = (*section)->Execute(&batch);
int64_t endTime = uptimeMillis();