Reduce memory footprint of LogEvent
This reduces the memory footprint by 16 bytes per LogEvent.
Test: atest statsd_test
Test: atest CtsStatsdHostTestCases
Bug: 154857643
Change-Id: I1e541816377ae8b14d789dc4d1f0a4ec91eef998
diff --git a/cmds/statsd/src/logd/LogEvent.cpp b/cmds/statsd/src/logd/LogEvent.cpp
index 10b1059..8ec0173 100644
--- a/cmds/statsd/src/logd/LogEvent.cpp
+++ b/cmds/statsd/src/logd/LogEvent.cpp
@@ -227,8 +227,8 @@
}
// Check if at least one node was successfully parsed.
if (mValues.size() - 1 > firstUidInChainIndex) {
- mAttributionChainStartIndex = firstUidInChainIndex;
- mAttributionChainEndIndex = mValues.size() - 1;
+ mAttributionChainStartIndex = static_cast<int8_t>(firstUidInChainIndex);
+ mAttributionChainEndIndex = static_cast<int8_t>(mValues.size() - 1);
}
parseAnnotations(numAnnotations, firstUidInChainIndex);
@@ -249,7 +249,7 @@
}
bool isUid = readNextValue<uint8_t>();
- if (isUid) mUidFieldIndex = mValues.size() - 1;
+ if (isUid) mUidFieldIndex = static_cast<int8_t>(mValues.size() - 1);
mValues[mValues.size() - 1].mAnnotations.setUidField(isUid);
}
@@ -290,7 +290,7 @@
}
const bool exclusiveState = readNextValue<uint8_t>();
- mExclusiveStateFieldIndex = mValues.size() - 1;
+ mExclusiveStateFieldIndex = static_cast<int8_t>(mValues.size() - 1);
mValues[getExclusiveStateFieldIndex()].mAnnotations.setExclusiveState(exclusiveState);
}
@@ -408,7 +408,7 @@
parseAttributionChain(pos, /*depth=*/0, last, getNumAnnotations(typeInfo));
break;
case ERROR_TYPE:
- mErrorBitmask = readNextValue<int32_t>();
+ /* mErrorBitmask =*/ readNextValue<int32_t>();
mValid = false;
break;
default:
@@ -577,8 +577,8 @@
}
if (nullptr != indexRange) {
- indexRange->first = mAttributionChainStartIndex;
- indexRange->second = mAttributionChainEndIndex;
+ indexRange->first = static_cast<int>(mAttributionChainStartIndex);
+ indexRange->second = static_cast<int>(mAttributionChainEndIndex);
}
return true;