Merge "Fix performance-for-range-copy warnings"
This commit is contained in:
@@ -106,14 +106,14 @@ void ConfigManager::UpdateConfig(const ConfigKey& key, const StatsdConfig& confi
|
||||
// Add to set.
|
||||
mConfigs[key.GetUid()].insert(key);
|
||||
|
||||
for (sp<ConfigListener> listener : mListeners) {
|
||||
for (const sp<ConfigListener>& listener : mListeners) {
|
||||
broadcastList.push_back(listener);
|
||||
}
|
||||
}
|
||||
|
||||
const int64_t timestampNs = getElapsedRealtimeNs();
|
||||
// Tell everyone
|
||||
for (sp<ConfigListener> listener : broadcastList) {
|
||||
for (const sp<ConfigListener>& listener : broadcastList) {
|
||||
listener->OnConfigUpdated(timestampNs, key, config);
|
||||
}
|
||||
}
|
||||
@@ -137,7 +137,7 @@ void ConfigManager::RemoveConfig(const ConfigKey& key) {
|
||||
if (uidIt != mConfigs.end() && uidIt->second.find(key) != uidIt->second.end()) {
|
||||
// Remove from map
|
||||
uidIt->second.erase(key);
|
||||
for (sp<ConfigListener> listener : mListeners) {
|
||||
for (const sp<ConfigListener>& listener : mListeners) {
|
||||
broadcastList.push_back(listener);
|
||||
}
|
||||
}
|
||||
@@ -153,7 +153,7 @@ void ConfigManager::RemoveConfig(const ConfigKey& key) {
|
||||
remove_saved_configs(key);
|
||||
}
|
||||
|
||||
for (sp<ConfigListener> listener:broadcastList) {
|
||||
for (const sp<ConfigListener>& listener:broadcastList) {
|
||||
listener->OnConfigRemoved(key);
|
||||
}
|
||||
}
|
||||
@@ -183,7 +183,7 @@ void ConfigManager::RemoveConfigs(int uid) {
|
||||
|
||||
mConfigs.erase(uidIt);
|
||||
|
||||
for (sp<ConfigListener> listener : mListeners) {
|
||||
for (const sp<ConfigListener>& listener : mListeners) {
|
||||
broadcastList.push_back(listener);
|
||||
}
|
||||
}
|
||||
@@ -191,7 +191,7 @@ void ConfigManager::RemoveConfigs(int uid) {
|
||||
// Remove separately so if they do anything in the callback they can't mess up our iteration.
|
||||
for (auto& key : removed) {
|
||||
// Tell everyone
|
||||
for (sp<ConfigListener> listener:broadcastList) {
|
||||
for (const sp<ConfigListener>& listener:broadcastList) {
|
||||
listener->OnConfigRemoved(key);
|
||||
}
|
||||
}
|
||||
@@ -213,7 +213,7 @@ void ConfigManager::RemoveAllConfigs() {
|
||||
}
|
||||
|
||||
mConfigReceivers.clear();
|
||||
for (sp<ConfigListener> listener : mListeners) {
|
||||
for (const sp<ConfigListener>& listener : mListeners) {
|
||||
broadcastList.push_back(listener);
|
||||
}
|
||||
}
|
||||
@@ -221,7 +221,7 @@ void ConfigManager::RemoveAllConfigs() {
|
||||
// Remove separately so if they do anything in the callback they can't mess up our iteration.
|
||||
for (auto& key : removed) {
|
||||
// Tell everyone
|
||||
for (sp<ConfigListener> listener:broadcastList) {
|
||||
for (const sp<ConfigListener>& listener:broadcastList) {
|
||||
listener->OnConfigRemoved(key);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -111,7 +111,7 @@ bool SubsystemSleepStatePuller::PullInternal(vector<shared_ptr<LogEvent>>* data)
|
||||
(long long)state.residencyInMsecSinceBoot,
|
||||
(long long)state.totalTransitions,
|
||||
state.supportedOnlyInSuspend ? 1 : 0);
|
||||
for (auto voter : state.voters) {
|
||||
for (const auto& voter : state.voters) {
|
||||
auto voterPtr = make_shared<LogEvent>(
|
||||
android::util::SUBSYSTEM_SLEEP_STATE,
|
||||
wallClockTimestampNs, elapsedTimestampNs);
|
||||
|
||||
@@ -395,7 +395,7 @@ void MetricsManager::onPeriodicAlarmFired(
|
||||
// Returns the total byte size of all metrics managed by a single config source.
|
||||
size_t MetricsManager::byteSize() {
|
||||
size_t totalSize = 0;
|
||||
for (auto metricProducer : mAllMetricProducers) {
|
||||
for (const auto& metricProducer : mAllMetricProducers) {
|
||||
totalSize += metricProducer->byteSize();
|
||||
}
|
||||
return totalSize;
|
||||
|
||||
@@ -537,7 +537,7 @@ bool initMetrics(const ConfigKey& key, const StatsdConfig& config,
|
||||
}
|
||||
noReportMetricIds.insert(no_report_metric);
|
||||
}
|
||||
for (auto it : allMetricProducers) {
|
||||
for (const auto& it : allMetricProducers) {
|
||||
uidMap.addListener(it);
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -141,7 +141,7 @@ void UidMap::updateMap(const int64_t& timestamp, const vector<int32_t>& uid,
|
||||
// listener removes itself before we call it. It's then the listener's job to handle it (expect
|
||||
// the callback to be called after listener is removed, and the listener should properly
|
||||
// ignore it).
|
||||
for (auto weakPtr : broadcastList) {
|
||||
for (const auto& weakPtr : broadcastList) {
|
||||
auto strongPtr = weakPtr.promote();
|
||||
if (strongPtr != NULL) {
|
||||
strongPtr->onUidMapReceived(timestamp);
|
||||
@@ -181,7 +181,7 @@ void UidMap::updateApp(const int64_t& timestamp, const String16& app_16, const i
|
||||
StatsdStats::getInstance().setUidMapChanges(mChanges.size());
|
||||
}
|
||||
|
||||
for (auto weakPtr : broadcastList) {
|
||||
for (const auto& weakPtr : broadcastList) {
|
||||
auto strongPtr = weakPtr.promote();
|
||||
if (strongPtr != NULL) {
|
||||
strongPtr->notifyAppUpgrade(timestamp, appName, uid, versionCode);
|
||||
@@ -248,7 +248,7 @@ void UidMap::removeApp(const int64_t& timestamp, const String16& app_16, const i
|
||||
getListenerListCopyLocked(&broadcastList);
|
||||
}
|
||||
|
||||
for (auto weakPtr : broadcastList) {
|
||||
for (const auto& weakPtr : broadcastList) {
|
||||
auto strongPtr = weakPtr.promote();
|
||||
if (strongPtr != NULL) {
|
||||
strongPtr->notifyAppRemoved(timestamp, app, uid);
|
||||
|
||||
@@ -71,12 +71,12 @@ bool detectAnomaliesPass(AnomalyTracker& tracker,
|
||||
const std::shared_ptr<DimToValMap>& currentBucket,
|
||||
const std::set<const MetricDimensionKey>& trueList,
|
||||
const std::set<const MetricDimensionKey>& falseList) {
|
||||
for (MetricDimensionKey key : trueList) {
|
||||
for (const MetricDimensionKey& key : trueList) {
|
||||
if (!tracker.detectAnomaly(bucketNum, key, getBucketValue(currentBucket, key))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
for (MetricDimensionKey key : falseList) {
|
||||
for (const MetricDimensionKey& key : falseList) {
|
||||
if (tracker.detectAnomaly(bucketNum, key, getBucketValue(currentBucket, key))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -414,7 +414,7 @@ static int UnmountTree(const char* path) {
|
||||
}
|
||||
endmntent(fp);
|
||||
|
||||
for (auto path : toUnmount) {
|
||||
for (const auto& path : toUnmount) {
|
||||
if (umount2(path.c_str(), MNT_DETACH)) {
|
||||
ALOGW("Failed to unmount %s: %s", path.c_str(), strerror(errno));
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ public:
|
||||
paint.setStrokeWidth(strokeWidth);
|
||||
// fill column with each op
|
||||
int middleCount = canvas.save(SaveFlags::MatrixClip);
|
||||
for (auto op : ops) {
|
||||
for (const auto& op : ops) {
|
||||
int innerCount = canvas.save(SaveFlags::MatrixClip);
|
||||
canvas.clipRect(0, 0, cellSize, cellSize, SkClipOp::kIntersect);
|
||||
canvas.drawColor(Color::White, SkBlendMode::kSrcOver);
|
||||
|
||||
@@ -251,7 +251,7 @@ static bool hasSameVerbs(const PathData& from, const PathData& to) {
|
||||
}
|
||||
|
||||
TEST(PathParser, parseStringForData) {
|
||||
for (TestData testData : sTestDataSet) {
|
||||
for (const TestData& testData : sTestDataSet) {
|
||||
PathParser::ParseResult result;
|
||||
// Test generated path data against the given data.
|
||||
PathData pathData;
|
||||
@@ -271,7 +271,7 @@ TEST(PathParser, parseStringForData) {
|
||||
}
|
||||
|
||||
TEST(VectorDrawableUtils, createSkPathFromPathData) {
|
||||
for (TestData testData : sTestDataSet) {
|
||||
for (const TestData& testData : sTestDataSet) {
|
||||
SkPath expectedPath;
|
||||
testData.skPathLamda(&expectedPath);
|
||||
SkPath actualPath;
|
||||
@@ -281,7 +281,7 @@ TEST(VectorDrawableUtils, createSkPathFromPathData) {
|
||||
}
|
||||
|
||||
TEST(PathParser, parseAsciiStringForSkPath) {
|
||||
for (TestData testData : sTestDataSet) {
|
||||
for (const TestData& testData : sTestDataSet) {
|
||||
PathParser::ParseResult result;
|
||||
size_t length = strlen(testData.pathString);
|
||||
// Check the return value as well as the SkPath generated.
|
||||
@@ -304,8 +304,8 @@ TEST(PathParser, parseAsciiStringForSkPath) {
|
||||
}
|
||||
|
||||
TEST(VectorDrawableUtils, morphPathData) {
|
||||
for (TestData fromData : sTestDataSet) {
|
||||
for (TestData toData : sTestDataSet) {
|
||||
for (const TestData& fromData : sTestDataSet) {
|
||||
for (const TestData& toData : sTestDataSet) {
|
||||
bool canMorph = VectorDrawableUtils::canMorph(fromData.pathData, toData.pathData);
|
||||
if (fromData.pathData == toData.pathData) {
|
||||
EXPECT_TRUE(canMorph);
|
||||
@@ -319,8 +319,8 @@ TEST(VectorDrawableUtils, morphPathData) {
|
||||
|
||||
TEST(VectorDrawableUtils, interpolatePathData) {
|
||||
// Interpolate path data with itself and every other path data
|
||||
for (TestData fromData : sTestDataSet) {
|
||||
for (TestData toData : sTestDataSet) {
|
||||
for (const TestData& fromData : sTestDataSet) {
|
||||
for (const TestData& toData : sTestDataSet) {
|
||||
PathData outData;
|
||||
bool success = VectorDrawableUtils::interpolatePathData(&outData, fromData.pathData,
|
||||
toData.pathData, 0.5);
|
||||
@@ -331,7 +331,7 @@ TEST(VectorDrawableUtils, interpolatePathData) {
|
||||
|
||||
float fractions[] = {0, 0.00001, 0.28, 0.5, 0.7777, 0.9999999, 1};
|
||||
// Now try to interpolate with a slightly modified version of self and expect success
|
||||
for (TestData fromData : sTestDataSet) {
|
||||
for (const TestData& fromData : sTestDataSet) {
|
||||
PathData toPathData = fromData.pathData;
|
||||
for (size_t i = 0; i < toPathData.points.size(); i++) {
|
||||
toPathData.points[i]++;
|
||||
|
||||
@@ -78,7 +78,7 @@ static uint32_t ParseFormatType(const StringPiece& piece) {
|
||||
|
||||
static uint32_t ParseFormatAttribute(const StringPiece& str) {
|
||||
uint32_t mask = 0;
|
||||
for (StringPiece part : util::Tokenize(str, '|')) {
|
||||
for (const StringPiece& part : util::Tokenize(str, '|')) {
|
||||
StringPiece trimmed_part = util::TrimWhitespace(part);
|
||||
uint32_t type = ParseFormatType(trimmed_part);
|
||||
if (type == 0) {
|
||||
|
||||
@@ -360,7 +360,7 @@ std::unique_ptr<BinaryPrimitive> TryParseFlagSymbol(const Attribute* flag_attr,
|
||||
return util::make_unique<BinaryPrimitive>(flags);
|
||||
}
|
||||
|
||||
for (StringPiece part : util::Tokenize(str, '|')) {
|
||||
for (const StringPiece& part : util::Tokenize(str, '|')) {
|
||||
StringPiece trimmed_part = util::TrimWhitespace(part);
|
||||
|
||||
bool flag_set = false;
|
||||
|
||||
@@ -486,7 +486,7 @@ static bool CompileXml(IAaptContext* context, const CompileOptions& options,
|
||||
}
|
||||
|
||||
Printer r_txt_printer(&fout_text);
|
||||
for (const auto res : xmlres->file.exported_symbols) {
|
||||
for (const auto& res : xmlres->file.exported_symbols) {
|
||||
r_txt_printer.Print("default int id ");
|
||||
r_txt_printer.Println(res.name.entry);
|
||||
}
|
||||
|
||||
@@ -113,7 +113,7 @@ void AnnotationProcessor::AppendNewLine() {
|
||||
void AnnotationProcessor::Print(Printer* printer) const {
|
||||
if (has_comments_) {
|
||||
std::string result = comment_.str();
|
||||
for (StringPiece line : util::Tokenize(result, '\n')) {
|
||||
for (const StringPiece& line : util::Tokenize(result, '\n')) {
|
||||
printer->Println(line);
|
||||
}
|
||||
printer->Println(" */");
|
||||
|
||||
@@ -165,7 +165,7 @@ void AppendPath(std::string* base, StringPiece part) {
|
||||
|
||||
std::string PackageToPath(const StringPiece& package) {
|
||||
std::string out_path;
|
||||
for (StringPiece part : util::Tokenize(package, '.')) {
|
||||
for (const StringPiece& part : util::Tokenize(package, '.')) {
|
||||
AppendPath(&out_path, part);
|
||||
}
|
||||
return out_path;
|
||||
|
||||
Reference in New Issue
Block a user