[glom] Replace find_if_layout_item_field_is_same_field_exists() with find_*_exists().



commit 1b5172f25e8772f3a4ecf84967298681ae9a5e03
Author: Murray Cumming <murrayc murrayc com>
Date:   Tue Jan 5 17:21:36 2016 +0100

    Replace find_if_layout_item_field_is_same_field_exists() with find_*_exists().
    
    Because we don't actuall use the iterator other than to check it against end().

 .../data_structure/layout/layoutitem_field.h       |    4 ++--
 glom/libglom/utils.cc                              |    8 ++------
 glom/mode_data/box_data_details.cc                 |    3 +--
 3 files changed, 5 insertions(+), 10 deletions(-)
---
diff --git a/glom/libglom/data_structure/layout/layoutitem_field.h 
b/glom/libglom/data_structure/layout/layoutitem_field.h
index 497e193..f2969f2 100644
--- a/glom/libglom/data_structure/layout/layoutitem_field.h
+++ b/glom/libglom/data_structure/layout/layoutitem_field.h
@@ -167,9 +167,9 @@ private:
  */
 template
 <typename T_Container>
-auto find_if_layout_item_field_is_same_field(T_Container& container, const std::shared_ptr<const 
LayoutItem_Field>& layout_item) -> decltype(container.begin())
+bool find_if_layout_item_field_is_same_field_exists(T_Container& container, const std::shared_ptr<const 
LayoutItem_Field>& layout_item)
 {
-  return Utils::find_if(container,
+  return Utils::find_if_exists(container,
     [&layout_item](const typename T_Container::value_type& element)
     {
       //Assume that element is a shared_ptr<>.
diff --git a/glom/libglom/utils.cc b/glom/libglom/utils.cc
index cc7b2b6..0335f48 100644
--- a/glom/libglom/utils.cc
+++ b/glom/libglom/utils.cc
@@ -1486,9 +1486,7 @@ LayoutGroup::type_list_const_items Utils::get_layout_items_plus_primary_key(cons
   pk_layout_item->set_hidden();
   pk_layout_item->set_full_field_details(field_primary_key);
   
-  const auto iterFind =
-    find_if_layout_item_field_is_same_field(items, pk_layout_item);
-  if(iterFind != items.end())
+  if(find_if_layout_item_field_is_same_field_exists(items, pk_layout_item))
     return items; //It is already in the list:
 
   LayoutGroup::type_list_const_items items_plus_pk = items;
@@ -1516,9 +1514,7 @@ LayoutGroup::type_list_items Utils::get_layout_items_plus_primary_key(const Layo
   pk_layout_item->set_hidden();
   pk_layout_item->set_full_field_details(field_primary_key);
   
-  const auto iterFind = 
-    find_if_layout_item_field_is_same_field(items, pk_layout_item);
-  if(iterFind != items.end())
+  if(find_if_layout_item_field_is_same_field_exists(items, pk_layout_item))
     return items; //It is already in the list:
 
   LayoutGroup::type_list_items items_plus_pk = items;
diff --git a/glom/mode_data/box_data_details.cc b/glom/mode_data/box_data_details.cc
index b119e20..024aa57 100644
--- a/glom/mode_data/box_data_details.cc
+++ b/glom/mode_data/box_data_details.cc
@@ -305,8 +305,7 @@ bool Box_Data_Details::fill_from_database()
         //TODO_Performance: Do this for create_layout() only, instead of repeating it for each refresh?:
         int index_primary_key = -1; //Arbitrary default.
         //g_warning("primary_key name = %s", m_field_primary_key->get_name().c_str());
-        const auto iterFind = find_if_layout_item_field_is_same_field(fieldsToGet, layout_item_pk);
-        if(iterFind == fieldsToGet.end())
+        if(!find_if_layout_item_field_is_same_field_exists(fieldsToGet, layout_item_pk))
         {
           fieldsToGet.push_back(layout_item_pk);
           index_primary_key = fieldsToGet.size() - 1;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]