diff options
author | David Kalnischkies <david@kalnischkies.de> | 2015-08-29 12:28:24 +0200 |
---|---|---|
committer | David Kalnischkies <david@kalnischkies.de> | 2015-08-29 12:33:30 +0200 |
commit | 8dd562a894c2472e3705fe13c212f665b55744a9 (patch) | |
tree | a042b35a689ba64e0a76207115fb937cefa8f0c2 /apt-pkg/aptconfiguration.cc | |
parent | d7a51997c30b2098bb60b3397095ec58ec825303 (diff) |
use c++11 algorithms to avoid strange compiler warnings
Nobody knows what makes the 'unable to optimize loop' warning to appear
in the sourceslist minus-options parsing, especially if we use a foreach
loop, but we can replace it with some nice c++11 algorithm+lambda usage,
which also helps in making even clearer what happens here.
And as this would be a lonely change, lets do it for a few more loops as
well where I might or might not have seen the warning at some point in
time, too.
Git-Dch: Ignore
Diffstat (limited to 'apt-pkg/aptconfiguration.cc')
-rw-r--r-- | apt-pkg/aptconfiguration.cc | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/apt-pkg/aptconfiguration.cc b/apt-pkg/aptconfiguration.cc index f5bc18394..ed68244c6 100644 --- a/apt-pkg/aptconfiguration.cc +++ b/apt-pkg/aptconfiguration.cc @@ -94,11 +94,9 @@ const Configuration::getCompressionTypes(bool const &Cached) { continue; // ignore types we have no app ready to use std::string const app = _config->Find(method); - std::vector<APT::Configuration::Compressor>::const_iterator c = compressors.begin(); - for (; c != compressors.end(); ++c) - if (c->Name == app) - break; - if (c == compressors.end()) + if (std::find_if(compressors.begin(), compressors.end(), [&app](APT::Configuration::Compressor const &c) { + return c.Name == app; + }) == compressors.end()) continue; types.push_back(*o); } @@ -115,11 +113,9 @@ const Configuration::getCompressionTypes(bool const &Cached) { if (std::find(types.begin(),types.end(),Types->Tag) != types.end()) continue; // ignore types we have no app ready to use - std::vector<APT::Configuration::Compressor>::const_iterator c = compressors.begin(); - for (; c != compressors.end(); ++c) - if (c->Name == Types->Value) - break; - if (c == compressors.end()) + if (std::find_if(compressors.begin(), compressors.end(), [&Types](APT::Configuration::Compressor const &c) { + return c.Name == Types->Value; + }) == compressors.end()) continue; types.push_back(Types->Tag); } |