Avoid going through char* for std::string API
Bug: 13186058
(cherry picked from commit 14ae4a873e91ae8cb1c00013579b5b058268879d)
Change-Id: Ib529cc10abc2d413e9da65c043dbc2638b734acd
diff --git a/runtime/utils.cc b/runtime/utils.cc
index 8e6ddaf..39a051c 100644
--- a/runtime/utils.cc
+++ b/runtime/utils.cc
@@ -1212,10 +1212,11 @@
// Convert the args to char pointers.
const char* program = arg_vector[0].c_str();
std::vector<char*> args;
- for (std::vector<std::string>::const_iterator it = arg_vector.begin(); it != arg_vector.end();
- ++it) {
- CHECK(*it != nullptr);
- args.push_back(const_cast<char*>(it->c_str()));
+ for (size_t i = 0; i < arg_vector.size(); ++i) {
+ const std::string& arg = arg_vector[i];
+ char* arg_str = const_cast<char*>(arg.c_str());
+ CHECK(arg_str != nullptr) << i;
+ args.push_back(arg_str);
}
args.push_back(NULL);