[glom] Avoid unnecessary copying when calling get_format_used().



commit 3fa9a741bd7f26f7d6045fb2b29c712e9bc0aaf0
Author: Murray Cumming <murrayc murrayc com>
Date:   Mon Nov 7 14:11:28 2016 +0100

    Avoid unnecessary copying when calling get_format_used().
    
    Noticed by
    clang-tidy-3.9 --checks=-*,performance-*

 .../data_structure/layout/layoutitem_field.cc      |    4 ++--
 .../layout/layoutitem_withformatting.cc            |    2 +-
 glom/mode_data/datawidget/cellcreation.cc          |    4 ++--
 .../mode_data/datawidget/combo_as_radio_buttons.cc |    2 +-
 .../datawidget/combochoiceswithtreemodel.cc        |    6 +++---
 glom/mode_data/db_adddel/db_adddel.cc              |    2 +-
 glom/mode_data/flowtablewithfields.cc              |    2 +-
 glom/print_layout/print_layout_utils.cc            |    2 +-
 glom/utility_widgets/layoutwidgetbase.cc           |    2 +-
 9 files changed, 13 insertions(+), 13 deletions(-)
---
diff --git a/glom/libglom/data_structure/layout/layoutitem_field.cc 
b/glom/libglom/data_structure/layout/layoutitem_field.cc
index a2224d4..eb608aa 100644
--- a/glom/libglom/data_structure/layout/layoutitem_field.cc
+++ b/glom/libglom/data_structure/layout/layoutitem_field.cc
@@ -251,7 +251,7 @@ const Formatting& LayoutItem_Field::get_formatting_used() const
 
 Formatting::HorizontalAlignment LayoutItem_Field::get_formatting_used_horizontal_alignment(bool 
for_details_view) const
 {
-  const auto format = get_formatting_used();
+  const auto& format = get_formatting_used();
   Formatting::HorizontalAlignment alignment =
     format.get_horizontal_alignment();
 
@@ -273,7 +273,7 @@ Formatting::HorizontalAlignment LayoutItem_Field::get_formatting_used_horizontal
 
 bool LayoutItem_Field::get_formatting_used_has_translatable_choices() const
 {
-  const auto formatting = get_formatting_used();
+  const auto& formatting = get_formatting_used();
   if(!formatting.get_has_custom_choices())
     return false;
 
diff --git a/glom/libglom/data_structure/layout/layoutitem_withformatting.cc 
b/glom/libglom/data_structure/layout/layoutitem_withformatting.cc
index daba8cb..4e8c21c 100644
--- a/glom/libglom/data_structure/layout/layoutitem_withformatting.cc
+++ b/glom/libglom/data_structure/layout/layoutitem_withformatting.cc
@@ -58,7 +58,7 @@ const Formatting& LayoutItem_WithFormatting::get_formatting_used() const
 
 Formatting::HorizontalAlignment LayoutItem_WithFormatting::get_formatting_used_horizontal_alignment(bool /* 
for_details_view */) const
 {
-  const auto format = get_formatting_used();
+  const auto& format = get_formatting_used();
   Formatting::HorizontalAlignment alignment =
     format.get_horizontal_alignment();
 
diff --git a/glom/mode_data/datawidget/cellcreation.cc b/glom/mode_data/datawidget/cellcreation.cc
index 62c9d1f..c98ec2f 100644
--- a/glom/mode_data/datawidget/cellcreation.cc
+++ b/glom/mode_data/datawidget/cellcreation.cc
@@ -45,7 +45,7 @@ static void apply_formatting(Gtk::CellRenderer* renderer, const std::shared_ptr<
   const float x_align = (alignment == Formatting::HorizontalAlignment::LEFT ? 0.0 : 1.0);
   text_renderer->property_xalign() = x_align;
 
-  const auto formatting = layout_item->get_formatting_used();
+  const auto& formatting = layout_item->get_formatting_used();
 
   const auto font_desc = formatting.get_text_format_font();
   if(!font_desc.empty())
@@ -96,7 +96,7 @@ Gtk::CellRenderer* create_cell(const std::shared_ptr<const LayoutItem>& layout_i
       }
       default:
       {
-        const auto formatting = item_field->get_formatting_used();
+        const auto& formatting = item_field->get_formatting_used();
         if(formatting.get_has_choices())
         {
           auto rendererList = Gtk::manage( new CellRendererDbList() );
diff --git a/glom/mode_data/datawidget/combo_as_radio_buttons.cc 
b/glom/mode_data/datawidget/combo_as_radio_buttons.cc
index 5b588c2..d2c7911 100644
--- a/glom/mode_data/datawidget/combo_as_radio_buttons.cc
+++ b/glom/mode_data/datawidget/combo_as_radio_buttons.cc
@@ -53,7 +53,7 @@ void ComboAsRadioButtons::set_choices_with_second(const type_list_values_with_se
 
   auto layout_item =
     std::dynamic_pointer_cast<LayoutItem_Field>(get_layout_item());
-  const auto format = layout_item->get_formatting_used();
+  const auto& format = layout_item->get_formatting_used();
   std::shared_ptr<const Relationship> choice_relationship;
   std::shared_ptr<const LayoutItem_Field> layout_choice_first;
   std::shared_ptr<const LayoutGroup> layout_choice_extra;
diff --git a/glom/mode_data/datawidget/combochoiceswithtreemodel.cc 
b/glom/mode_data/datawidget/combochoiceswithtreemodel.cc
index 74ba43d..34d95b7 100644
--- a/glom/mode_data/datawidget/combochoiceswithtreemodel.cc
+++ b/glom/mode_data/datawidget/combochoiceswithtreemodel.cc
@@ -118,7 +118,7 @@ void ComboChoicesWithTreeModel::set_choices_with_second(const type_list_values_w
   //Fill the model with data:
   auto layout_item =
     std::dynamic_pointer_cast<LayoutItem_Field>(get_layout_item());
-  const auto format = layout_item->get_formatting_used();
+  const auto& format = layout_item->get_formatting_used();
   std::shared_ptr<const Relationship> choice_relationship;
   std::shared_ptr<const LayoutItem_Field> layout_choice_first;
   std::shared_ptr<const LayoutGroup> layout_choice_extra;
@@ -237,7 +237,7 @@ void ComboChoicesWithTreeModel::set_choices_related(const std::shared_ptr<const
     return;
   }
 
-  const auto format = layout_field.get_formatting_used();
+  const auto& format = layout_field.get_formatting_used();
   std::shared_ptr<const Relationship> choice_relationship;
   std::shared_ptr<const LayoutItem_Field> layout_choice_first;
   std::shared_ptr<const LayoutGroup> layout_choice_extra;
@@ -439,7 +439,7 @@ int ComboChoicesWithTreeModel::get_fixed_cell_height(Gtk::Widget& widget)
       const auto item_withformatting = std::dynamic_pointer_cast<const LayoutItem_WithFormatting>(item);
       if(item_withformatting)
       {
-         const auto formatting = item_withformatting->get_formatting_used();
+         const auto& formatting = item_withformatting->get_formatting_used();
          font_name = formatting.get_text_format_font();
       }
 
diff --git a/glom/mode_data/db_adddel/db_adddel.cc b/glom/mode_data/db_adddel/db_adddel.cc
index ec20cda..00af2f0 100644
--- a/glom/mode_data/db_adddel/db_adddel.cc
+++ b/glom/mode_data/db_adddel/db_adddel.cc
@@ -1009,7 +1009,7 @@ DbAddDel::type_list_indexes DbAddDel::get_choice_index(const LayoutItem_Field& f
     if(!field)
        continue;
 
-    const auto format = field->get_formatting_used();
+    const auto& format = field->get_formatting_used();
 
     bool choice_show_all = false;
     const auto choice_relationship =
diff --git a/glom/mode_data/flowtablewithfields.cc b/glom/mode_data/flowtablewithfields.cc
index 9153138..2969e9f 100644
--- a/glom/mode_data/flowtablewithfields.cc
+++ b/glom/mode_data/flowtablewithfields.cc
@@ -837,7 +837,7 @@ FlowTableWithFields::type_choice_widgets FlowTableWithFields::get_choice_widgets
     if(!field)
       continue;
 
-    const auto format = field->get_formatting_used();
+    const auto& format = field->get_formatting_used();
 
     bool choice_show_all = false;
     const auto choice_relationship =
diff --git a/glom/print_layout/print_layout_utils.cc b/glom/print_layout/print_layout_utils.cc
index dcfaa00..8d2d6aa 100644
--- a/glom/print_layout/print_layout_utils.cc
+++ b/glom/print_layout/print_layout_utils.cc
@@ -273,7 +273,7 @@ static void create_standard(const std::shared_ptr<const LayoutGroup>& layout_gro
       double this_field_height = field_height;
       if(field)
       {
-        const auto formatting = field->get_formatting_used();
+        const auto& formatting = field->get_formatting_used();
         if(formatting.get_text_format_multiline())
         {
           const auto lines = formatting.get_text_format_multiline_height_lines();
diff --git a/glom/utility_widgets/layoutwidgetbase.cc b/glom/utility_widgets/layoutwidgetbase.cc
index 2a88f42..46b5e87 100644
--- a/glom/utility_widgets/layoutwidgetbase.cc
+++ b/glom/utility_widgets/layoutwidgetbase.cc
@@ -142,7 +142,7 @@ void LayoutWidgetBase::apply_formatting(Gtk::Widget& widget, const LayoutItem_Wi
     }
   }
 
-  const auto formatting = layout_item.get_formatting_used();
+  const auto& formatting = layout_item.get_formatting_used();
 
   //Use the text formatting:
   const auto font_desc = formatting.get_text_format_font();


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