From 8f37932efdbf7585c85ba1e7653e7080e17d7714 Mon Sep 17 00:00:00 2001
From: Willem Jan Palenstijn <Willem.Jan.Palenstijn@cwi.nl>
Date: Thu, 23 Jul 2015 11:39:28 +0200
Subject: Reduce code duplication

---
 include/astra/AstraObjectFactory.h | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

(limited to 'include')

diff --git a/include/astra/AstraObjectFactory.h b/include/astra/AstraObjectFactory.h
index 1ed4955..efe997d 100644
--- a/include/astra/AstraObjectFactory.h
+++ b/include/astra/AstraObjectFactory.h
@@ -109,14 +109,11 @@ T* CAstraObjectFactory<T, TypeList>::create(std::string _sType)
 template <typename T, typename TypeList>
 T* CAstraObjectFactory<T, TypeList>::create(const Config& _cfg)
 {
-	functor_find<T> finder = functor_find<T>();
-	finder.tofind = _cfg.self.getAttribute("type");
-	CreateObject<TypeList>::find(finder);
-	if (finder.res == NULL) return NULL;
-	if (finder.res->initialize(_cfg))
-		return finder.res;
-
-	delete finder.res;
+	T* object = create(_cfg.self.getAttribute("type"));
+	if (object == NULL) return NULL;
+	if (object->initialize(_cfg))
+		return object;
+	delete object;
 	return NULL;
 }
 //----------------------------------------------------------------------------------------
-- 
cgit v1.2.3