From 5645ad8275f7dfd9e75fe208b7bbdbed819e2adf Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Wed, 25 Aug 2021 21:20:02 -0700 Subject: [PATCH] Modernize MinidumpCrashpadInfo::Print(). Use range-based for-loops where appropriate. Change-Id: I2fffd270d434c90850e8151ee40e5adf0736ce55 Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/3120666 Reviewed-by: Joshua Peraza --- src/processor/minidump.cc | 32 ++++++++++++-------------------- 1 file changed, 12 insertions(+), 20 deletions(-) diff --git a/src/processor/minidump.cc b/src/processor/minidump.cc index aab0e9fb..9aef25ec 100644 --- a/src/processor/minidump.cc +++ b/src/processor/minidump.cc @@ -4983,12 +4983,9 @@ void MinidumpCrashpadInfo::Print() { MDGUIDToString(crashpad_info_.report_id).c_str()); printf(" client_id = %s\n", MDGUIDToString(crashpad_info_.client_id).c_str()); - for (std::map::const_iterator iterator = - simple_annotations_.begin(); - iterator != simple_annotations_.end(); - ++iterator) { - printf(" simple_annotations[\"%s\"] = %s\n", - iterator->first.c_str(), iterator->second.c_str()); + for (const auto& annot : simple_annotations_) { + printf(" simple_annotations[\"%s\"] = %s\n", annot.first.c_str(), + annot.second.c_str()); } for (uint32_t module_index = 0; module_index < module_crashpad_info_links_.size(); @@ -4997,23 +4994,18 @@ void MinidumpCrashpadInfo::Print() { module_index, module_crashpad_info_links_[module_index]); printf(" module_list[%d].version = %d\n", module_index, module_crashpad_info_[module_index].version); - for (uint32_t annotation_index = 0; - annotation_index < - module_crashpad_info_list_annotations_[module_index].size(); + const auto& list_annots = + module_crashpad_info_list_annotations_[module_index]; + for (uint32_t annotation_index = 0; annotation_index < list_annots.size(); ++annotation_index) { - printf(" module_list[%d].list_annotations[%d] = %s\n", - module_index, - annotation_index, - module_crashpad_info_list_annotations_ - [module_index][annotation_index].c_str()); + printf(" module_list[%d].list_annotations[%d] = %s\n", module_index, + annotation_index, list_annots[annotation_index].c_str()); } - for (std::map::const_iterator iterator = - module_crashpad_info_simple_annotations_[module_index].begin(); - iterator != - module_crashpad_info_simple_annotations_[module_index].end(); - ++iterator) { + const auto& simple_annots = + module_crashpad_info_simple_annotations_[module_index]; + for (const auto& annot : simple_annots) { printf(" module_list[%d].simple_annotations[\"%s\"] = %s\n", - module_index, iterator->first.c_str(), iterator->second.c_str()); + module_index, annot.first.c_str(), annot.second.c_str()); } }