From 8dd562a894c2472e3705fe13c212f665b55744a9 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Sat, 29 Aug 2015 12:28:24 +0200 Subject: 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 --- apt-pkg/aptconfiguration.cc | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) (limited to 'apt-pkg/aptconfiguration.cc') 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::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::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); } -- cgit v1.2.3