From 0787ce8814e37972a0c968f60008d4e8722b6e27 Mon Sep 17 00:00:00 2001 From: Arkadiy Illarionov Date: Wed, 15 Aug 2018 21:32:27 +0300 Subject: Simplify containers iterations, tdf#96099 follow-up Use range-based loop or replace with std::any_of, std::find and std::find_if where applicable. Change-Id: I2f80788c49d56094c29b102eb96a7a7c079567c6 Reviewed-on: https://gerrit.libreoffice.org/59143 Tested-by: Jenkins Reviewed-by: Michael Meeks Reviewed-by: Noel Grandin --- sal/qa/osl/process/osl_process.cxx | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) (limited to 'sal/qa') diff --git a/sal/qa/osl/process/osl_process.cxx b/sal/qa/osl/process/osl_process.cxx index 317682238e49..08b39e1e8357 100644 --- a/sal/qa/osl/process/osl_process.cxx +++ b/sal/qa/osl/process/osl_process.cxx @@ -92,10 +92,8 @@ public: explicit exclude(const std::vector& exclude_list) { - auto iter = exclude_list.cbegin(); - auto iter_end = exclude_list.cend(); - for (/**/; iter != iter_end; ++iter) - exclude_list_.push_back(env_var_name(*iter)); + for (auto& exclude_list_item : exclude_list) + exclude_list_.push_back(env_var_name(exclude_list_item)); } bool operator() (const OString& env_var) const @@ -259,8 +257,8 @@ public: std::vector parent_env; read_parent_environment(&parent_env); - for (auto iter = parent_env.cbegin(), end = parent_env.cend(); iter != end; ++iter) - std::cout << "initially parent env: " << *iter << "\n"; + for (auto& env : parent_env) + std::cout << "initially parent env: " << env << "\n"; //remove the environment variables that we have changed //in the child environment from the read parent environment @@ -268,16 +266,16 @@ public: std::remove_if(parent_env.begin(), parent_env.end(), exclude(different_env_vars)), parent_env.end()); - for (auto iter = parent_env.cbegin(), end = parent_env.cend(); iter != end; ++iter) - std::cout << "stripped parent env: " << *iter << "\n"; + for (auto& env : parent_env) + std::cout << "stripped parent env: " << env << "\n"; //read the child environment and exclude the variables that //are different std::vector child_env; read_child_environment(&child_env); - for (auto iter = child_env.cbegin(), end = child_env.cend(); iter != end; ++iter) - std::cout << "initial child env: " << *iter << "\n"; + for (auto& env : child_env) + std::cout << "initial child env: " << env << "\n"; //partition the child environment into the variables that //are different to the parent environment (they come first) //and the variables that should be equal between parent @@ -288,17 +286,17 @@ public: std::vector different_child_env_vars(child_env.begin(), iter_logical_end); child_env.erase(child_env.begin(), iter_logical_end); - for (auto iter = child_env.cbegin(), end = child_env.cend(); iter != end; ++iter) - std::cout << "stripped child env: " << *iter << "\n"; + for (auto& env : child_env) + std::cout << "stripped child env: " << env << "\n"; bool common_env_size_equals = (parent_env.size() == child_env.size()); bool common_env_content_equals = std::equal(child_env.begin(), child_env.end(), parent_env.begin()); - for (auto iter = different_env_vars.cbegin(), end = different_env_vars.cend(); iter != end; ++iter) - std::cout << "different should be: " << *iter << "\n"; + for (auto& env_var : different_env_vars) + std::cout << "different should be: " << env_var << "\n"; - for (auto iter = different_child_env_vars.cbegin(), end = different_child_env_vars.cend(); iter != end; ++iter) - std::cout << "different are: " << *iter << "\n"; + for (auto& env_var : different_child_env_vars) + std::cout << "different are: " << env_var << "\n"; bool different_env_size_equals = (different_child_env_vars.size() == different_env_vars.size()); bool different_env_content_equals = -- cgit