From afc8eb29c22447fe2bf71a503a5f2d25b4f8a7c7 Mon Sep 17 00:00:00 2001
From: Adrian Kummerländer
Date: Fri, 23 May 2014 20:13:42 +0200
Subject: Changed iterate functor parameter to const reference * replaced
 ranged for loop with more appropriate std::for_each

---
 src/support/filesystem_context.cc | 38 ++++++++++++++++++++------------------
 src/support/filesystem_context.h  | 20 ++++++++++++++------
 2 files changed, 34 insertions(+), 24 deletions(-)

(limited to 'src/support')

diff --git a/src/support/filesystem_context.cc b/src/support/filesystem_context.cc
index 8395046..a30bccc 100644
--- a/src/support/filesystem_context.cc
+++ b/src/support/filesystem_context.cc
@@ -28,9 +28,23 @@ boost::filesystem::path FilesystemContext::resolve(
 	return this->resolve(toString(path));
 }
 
+void FilesystemContext::iterate(
+	const std::string& path,
+	const std::function<void(const boost::filesystem::path&)>& func
+) const {
+	this->iterate(this->resolve(path), func);
+}
+
+void FilesystemContext::iterate(
+	const xalan::XalanDOMString& path,
+	const std::function<void(const boost::filesystem::path&)>& func
+) const {
+	this->iterate(toString(path), func);
+}
+
 void FilesystemContext::iterate(
 	const boost::filesystem::path& directory,
-	std::function<void(const boost::filesystem::path&)> func
+	const std::function<void(const boost::filesystem::path&)>& func
 ) const {
 	std::vector<boost::filesystem::path> directoryItems;
 
@@ -49,23 +63,11 @@ void FilesystemContext::iterate(
 		directoryItems.end()
 	);
 
-	for ( auto&& item : directoryItems ) {
-		func(item);
-	}
-}
-
-void FilesystemContext::iterate(
-	const std::string& path,
-	std::function<void(const boost::filesystem::path&)> func
-) const {
-	this->iterate(this->resolve(path), func);
-}
-
-void FilesystemContext::iterate(
-	const xalan::XalanDOMString& path,
-	std::function<void(const boost::filesystem::path&)> func
-) const {
-	this->iterate(toString(path), func);
+	std::for_each(
+		directoryItems.begin(),
+		directoryItems.end(),
+		func
+	);
 }
 
 }
diff --git a/src/support/filesystem_context.h b/src/support/filesystem_context.h
index 6322da6..1f574de 100644
--- a/src/support/filesystem_context.h
+++ b/src/support/filesystem_context.h
@@ -21,12 +21,20 @@ class FilesystemContext {
 		boost::filesystem::path resolve(const std::string&) const;
 		boost::filesystem::path resolve(const xalan::XalanDOMString&) const;
 
-		void iterate(const boost::filesystem::path&,
-		             std::function<void(const boost::filesystem::path&)>) const;
-		void iterate(const std::string&,
-		             std::function<void(const boost::filesystem::path&)>) const;
-		void iterate(const xalan::XalanDOMString&,
-		             std::function<void(const boost::filesystem::path&)>) const;
+		void iterate(
+			const std::string&,
+			const std::function<void(const boost::filesystem::path&)>&
+		) const;
+
+		void iterate(
+			const xalan::XalanDOMString&,
+			const std::function<void(const boost::filesystem::path&)>&
+		) const;
+
+		void iterate(
+			const boost::filesystem::path&,
+			const std::function<void(const boost::filesystem::path&)>&
+		) const;
 
 	private:
 		const boost::filesystem::path path_;
-- 
cgit v1.2.3