Fix up TODO: c++0x, update cpplint.
Needed to update cpplint to handle const auto.
Fixed a few cpplint errors that were being missed before.
Replaced most of the TODO c++0x with ranged based loops. Loops which
do not have a descriptive container name have a concrete type instead
of auto.
Change-Id: Id7cc0f27030f56057c544e94277300b3f298c9c5
diff --git a/runtime/class_linker.cc b/runtime/class_linker.cc
index 039e7bc..ef27321 100644
--- a/runtime/class_linker.cc
+++ b/runtime/class_linker.cc
@@ -1111,16 +1111,15 @@
Thread* self = Thread::Current();
{
ReaderMutexLock mu(self, dex_lock_);
- for (size_t i = 0; i < dex_caches_.size(); i++) {
- visitor(dex_caches_[i], arg);
+ for (mirror::DexCache* dex_cache : dex_caches_) {
+ visitor(dex_cache, arg);
}
}
{
ReaderMutexLock mu(self, *Locks::classlinker_classes_lock_);
- typedef Table::const_iterator It; // TODO: C++0x auto
- for (It it = classes_.begin(), end = classes_.end(); it != end; ++it) {
- visitor(it->second, arg);
+ for (const std::pair<size_t, mirror::Class*>& it : classes_) {
+ visitor(it.second, arg);
}
// We deliberately ignore the class roots in the image since we
@@ -1135,14 +1134,13 @@
void ClassLinker::VisitClasses(ClassVisitor* visitor, void* arg) const {
ReaderMutexLock mu(Thread::Current(), *Locks::classlinker_classes_lock_);
- typedef Table::const_iterator It; // TODO: C++0x auto
- for (It it = classes_.begin(), end = classes_.end(); it != end; ++it) {
- if (!visitor(it->second, arg)) {
+ for (const std::pair<size_t, mirror::Class*>& it : classes_) {
+ if (!visitor(it.second, arg)) {
return;
}
}
- for (It it = image_classes_.begin(), end = image_classes_.end(); it != end; ++it) {
- if (!visitor(it->second, arg)) {
+ for (const std::pair<size_t, mirror::Class*>& it : image_classes_) {
+ if (!visitor(it.second, arg)) {
return;
}
}
@@ -1157,9 +1155,8 @@
void ClassLinker::VisitClassesWithoutClassesLock(ClassVisitor* visitor, void* arg) const {
std::set<mirror::Class*> classes;
VisitClasses(GetClassesVisitor, &classes);
- typedef std::set<mirror::Class*>::const_iterator It; // TODO: C++0x auto
- for (It it = classes.begin(), end = classes.end(); it != end; ++it) {
- if (!visitor(*it, arg)) {
+ for (mirror::Class* klass : classes) {
+ if (!visitor(klass, arg)) {
return;
}
}
@@ -2160,10 +2157,9 @@
bool ClassLinker::RemoveClass(const char* descriptor, const mirror::ClassLoader* class_loader) {
size_t hash = Hash(descriptor);
WriterMutexLock mu(Thread::Current(), *Locks::classlinker_classes_lock_);
- typedef Table::iterator It; // TODO: C++0x auto
// TODO: determine if its better to search classes_ or image_classes_ first
ClassHelper kh;
- for (It it = classes_.lower_bound(hash), end = classes_.end(); it != end && it->first == hash;
+ for (auto it = classes_.lower_bound(hash), end = classes_.end(); it != end && it->first == hash;
++it) {
mirror::Class* klass = it->second;
kh.ChangeClass(klass);
@@ -2172,7 +2168,7 @@
return true;
}
}
- for (It it = image_classes_.lower_bound(hash), end = classes_.end();
+ for (auto it = image_classes_.lower_bound(hash), end = classes_.end();
it != end && it->first == hash; ++it) {
mirror::Class* klass = it->second;
kh.ChangeClass(klass);
@@ -2204,8 +2200,9 @@
const mirror::ClassLoader* class_loader,
size_t hash, const Table& classes) {
ClassHelper kh(NULL, this);
- typedef Table::const_iterator It; // TODO: C++0x auto
- for (It it = classes.lower_bound(hash), end = classes_.end(); it != end && it->first == hash; ++it) {
+ auto end = classes_.end();
+ for (auto it = classes.lower_bound(hash); it != end && it->first == hash;
+ ++it) {
mirror::Class* klass = it->second;
kh.ChangeClass(klass);
if (strcmp(descriptor, kh.GetDescriptor()) == 0 && klass->GetClassLoader() == class_loader) {
@@ -2228,17 +2225,18 @@
classes.clear();
size_t hash = Hash(descriptor);
ReaderMutexLock mu(Thread::Current(), *Locks::classlinker_classes_lock_);
- typedef Table::const_iterator It; // TODO: C++0x auto
// TODO: determine if its better to search classes_ or image_classes_ first
ClassHelper kh(NULL, this);
- for (It it = classes_.lower_bound(hash), end = classes_.end(); it != end && it->first == hash; ++it) {
+ for (auto it = classes_.lower_bound(hash), end = classes_.end(); it != end && it->first == hash;
+ ++it) {
mirror::Class* klass = it->second;
kh.ChangeClass(klass);
if (strcmp(descriptor, kh.GetDescriptor()) == 0) {
classes.push_back(klass);
}
}
- for (It it = image_classes_.lower_bound(hash), end = classes_.end(); it != end && it->first == hash; ++it) {
+ for (auto it = image_classes_.lower_bound(hash), end = classes_.end();
+ it != end && it->first == hash; ++it) {
mirror::Class* klass = it->second;
kh.ChangeClass(klass);
if (strcmp(descriptor, kh.GetDescriptor()) == 0) {
@@ -3967,12 +3965,11 @@
std::vector<mirror::Class*> all_classes;
{
ReaderMutexLock mu(Thread::Current(), *Locks::classlinker_classes_lock_);
- typedef Table::const_iterator It; // TODO: C++0x auto
- for (It it = classes_.begin(), end = classes_.end(); it != end; ++it) {
- all_classes.push_back(it->second);
+ for (const std::pair<size_t, mirror::Class*>& it : classes_) {
+ all_classes.push_back(it.second);
}
- for (It it = image_classes_.begin(), end = image_classes_.end(); it != end; ++it) {
- all_classes.push_back(it->second);
+ for (const std::pair<size_t, mirror::Class*>& it : image_classes_) {
+ all_classes.push_back(it.second);
}
}