C++11: Cleaned up program framework with range-based for
This commit is contained in:
13
src/util.cpp
13
src/util.cpp
@@ -156,23 +156,22 @@ int autoComplete (
|
||||
unsigned int length = partial.length ();
|
||||
if (length)
|
||||
{
|
||||
std::vector <std::string>::const_iterator item;
|
||||
for (item = list.begin (); item != list.end (); ++item)
|
||||
for (auto& item : list)
|
||||
{
|
||||
// An exact match is a special case. Assume there is only one exact match
|
||||
// and return immediately.
|
||||
if (partial == *item)
|
||||
if (partial == item)
|
||||
{
|
||||
matches.clear ();
|
||||
matches.push_back (*item);
|
||||
matches.push_back (item);
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Maintain a list of partial matches.
|
||||
else if (length >= (unsigned) minimum &&
|
||||
length <= item->length () &&
|
||||
partial == item->substr (0, length))
|
||||
matches.push_back (*item);
|
||||
length <= item.length () &&
|
||||
partial == item.substr (0, length))
|
||||
matches.push_back (item);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user