[glom] Replace most std::list with std::vector.



commit 54ac437923a7a85a506f200b127d55b2dc054228
Author: Murray Cumming <murrayc murrayc com>
Date:   Sun Nov 6 21:56:40 2016 +0100

    Replace most std::list with std::vector.
    
    Because vectors generally have better performance, because they
    are contiguous, without pointer chasing.
    Most of these uses are small vectors being built up gradually,
    but the small object optimization should help there.

 glom/appwindow.h                                   |    2 +-
 glom/bakery/appwindow_withdoc.h                    |    2 +-
 glom/base_db.h                                     |    4 ++--
 glom/import_csv/file_encodings.h                   |    4 ++--
 glom/mode_data/box_data_calendar_related.h         |    2 +-
 glom/mode_data/db_adddel/db_adddel.h               |    2 +-
 glom/mode_data/flowtablewithfields.h               |   16 ++++++++--------
 glom/mode_design/iso_codes.cc                      |    2 +-
 glom/mode_design/iso_codes.h                       |    4 ++--
 glom/mode_design/layout/dialog_choose_field.h      |    2 +-
 .../layout/dialog_layout_calendar_related.cc       |    2 +-
 glom/mode_design/layout/dialog_layout_details.cc   |    2 +-
 .../layout/dialog_layout_list_related.cc           |    2 +-
 glom/mode_design/users/dialog_groups_list.cc       |    2 +-
 glom/python_embed/glom_python.cc                   |    6 +++---
 glom/test_pyembed.cc                               |    6 +++---
 glom/utility_widgets/dialog_properties.h           |    2 +-
 glom/utility_widgets/flowtable.h                   |    4 ++--
 glom/utility_widgets/test_flowtable.cc             |    2 +-
 glom/utils_ui.cc                                   |    2 +-
 20 files changed, 35 insertions(+), 35 deletions(-)
---
diff --git a/glom/appwindow.h b/glom/appwindow.h
index 994a3d0..9e1ca93 100644
--- a/glom/appwindow.h
+++ b/glom/appwindow.h
@@ -292,7 +292,7 @@ private:
 #endif // !G_OS_WIN32
 
   //Widgets:
-  typedef std::list< Glib::RefPtr<Gio::SimpleAction> > type_listActions;
+  typedef std::vector< Glib::RefPtr<Gio::SimpleAction> > type_listActions;
   type_listActions m_listDeveloperActions; //Only enabled when in developer mode.
   type_listActions m_listTableSensitiveActions; // Only enabled when a table is loaded.
   Glib::RefPtr<Gio::SimpleAction> m_action_mode_find;
diff --git a/glom/bakery/appwindow_withdoc.h b/glom/bakery/appwindow_withdoc.h
index 8e30e8d..287a42f 100644
--- a/glom/bakery/appwindow_withdoc.h
+++ b/glom/bakery/appwindow_withdoc.h
@@ -169,7 +169,7 @@ protected:
   bool m_close_after_save;
 
   //Mime types which this application can load and save:
-  typedef std::list<Glib::ustring> type_list_strings;
+  typedef std::vector<Glib::ustring> type_list_strings;
   static type_list_strings m_mime_types;
 };
 
diff --git a/glom/base_db.h b/glom/base_db.h
index 87a94b1..4083c29 100644
--- a/glom/base_db.h
+++ b/glom/base_db.h
@@ -87,8 +87,8 @@ protected:
 
   void clear_fields_calculation_in_progress();
 
-  typedef std::list< std::shared_ptr<LayoutItem_Field> > type_list_field_items;
-  typedef std::list< std::shared_ptr<const LayoutItem_Field> > type_list_const_field_items;
+  typedef std::vector< std::shared_ptr<LayoutItem_Field> > type_list_field_items;
+  typedef std::vector< std::shared_ptr<const LayoutItem_Field> > type_list_const_field_items;
 
 #ifndef GLOM_ENABLE_CLIENT_ONLY
   /** Allow the user to select a field from the list of fields for the table.
diff --git a/glom/import_csv/file_encodings.h b/glom/import_csv/file_encodings.h
index 88a0a26..ea299d7 100644
--- a/glom/import_csv/file_encodings.h
+++ b/glom/import_csv/file_encodings.h
@@ -22,7 +22,7 @@
 #define GLOM_IMPORT_CSV_FILE_ENCODINGS_H
 
 #include <glibmm/ustring.h>
-#include <list>
+#include <vector>
 
 namespace Glom
 {
@@ -43,7 +43,7 @@ private:
   const char* m_charset;
 };
 
-typedef std::list<Encoding> type_list_encodings;
+typedef std::vector<Encoding> type_list_encodings;
 
 /** Get a list of file encodings to offer to the user.
  */
diff --git a/glom/mode_data/box_data_calendar_related.h b/glom/mode_data/box_data_calendar_related.h
index 3684a89..3a1e740 100644
--- a/glom/mode_data/box_data_calendar_related.h
+++ b/glom/mode_data/box_data_calendar_related.h
@@ -97,7 +97,7 @@ private:
   //The cached data for the month:
   //For each date we have a list of rows (vectors):
   typedef std::vector<Gnome::Gda::Value> type_vector_values;
-  typedef std::list<type_vector_values*> type_list_vectors;
+  typedef std::vector<type_vector_values*> type_list_vectors;
 
   // TODO: Use std::unordered_map, maybe like this:
   //static constexpr auto date_hash = [](const Glib::Date& date) {
diff --git a/glom/mode_data/db_adddel/db_adddel.h b/glom/mode_data/db_adddel/db_adddel.h
index 002af7a..922fac9 100644
--- a/glom/mode_data/db_adddel/db_adddel.h
+++ b/glom/mode_data/db_adddel/db_adddel.h
@@ -286,7 +286,7 @@ private:
   bool get_model_column_index(guint view_column_index, guint& model_column_index);
 
 
-  typedef std::list<guint> type_list_indexes;
+  typedef std::vector<guint> type_list_indexes;
   ///Return the column indexes of any columns that display this field.
   type_list_indexes get_column_index(const LayoutItem& layout_item) const;
 
diff --git a/glom/mode_data/flowtablewithfields.h b/glom/mode_data/flowtablewithfields.h
index be165a5..a24615e 100644
--- a/glom/mode_data/flowtablewithfields.h
+++ b/glom/mode_data/flowtablewithfields.h
@@ -44,7 +44,7 @@
 #include <gtkmm/eventbox.h>
 #include <gtkmm/box.h>
 #include <unordered_map>
-#include <list>
+#include <vector>
 
 namespace Glom
 {
@@ -107,8 +107,8 @@ public:
    */
   void update_choices(const LayoutItem_Field& field);
 
-  typedef std::list<Gtk::Widget*> type_list_widgets;
-  typedef std::list<const Gtk::Widget*> type_list_const_widgets;
+  typedef std::vector<Gtk::Widget*> type_list_widgets;
+  typedef std::vector<const Gtk::Widget*> type_list_const_widgets;
 
   void set_design_mode(bool value = true) override;
 
@@ -184,13 +184,13 @@ private:
   type_list_widgets get_field(const LayoutItem_Field& field, bool include_item);
   type_list_const_widgets get_field(const LayoutItem_Field& field, bool include_item) const;
 
-  typedef std::list<Box_Data_Portal*> type_portals;
+  typedef std::vector<Box_Data_Portal*> type_portals;
 
   /// Get portals whose relationships have @a from_key as the from_key.
   type_portals get_portals(const LayoutItem_Field& from_key);
 
 
-  typedef std::list<DataWidgetChildren::ComboChoices*> type_choice_widgets;
+  typedef std::vector<DataWidgetChildren::ComboChoices*> type_choice_widgets;
 
   /// Get choice widgets with !show_all relationships that have @a from_key as the from_key.
   type_choice_widgets get_choice_widgets(const LayoutItem_Field& from_key);
@@ -229,15 +229,15 @@ private:
   };
 
   //Map of IDs to full info.
-  std::list<Info> m_listFields;
+  std::vector<Info> m_listFields;
 
   //Remember the nested FlowTables, so that we can search them for fields too:
-  std::list< FlowTableWithFields* > m_sub_flow_tables;
+  std::vector<FlowTableWithFields*> m_sub_flow_tables;
 
   type_portals m_portals;
 
   //Remember the sequence of LayoutWidgetBase widgets, so we can iterate over them later:
-  std::list<LayoutWidgetBase*> m_list_layoutwidgets;
+  std::vector<LayoutWidgetBase*> m_list_layoutwidgets;
 
   void add_button(const std::shared_ptr<LayoutItem_Button>& layoutitem_button, const Glib::ustring& 
table_name);
   void add_textobject(const std::shared_ptr<LayoutItem_Text>& layoutitem_text, const Glib::ustring& 
table_name);
diff --git a/glom/mode_design/iso_codes.cc b/glom/mode_design/iso_codes.cc
index 2521708..520737a 100644
--- a/glom/mode_design/iso_codes.cc
+++ b/glom/mode_design/iso_codes.cc
@@ -111,7 +111,7 @@ Glib::ustring get_locale_name(const Glib::ustring& locale_id)
   if(map_locales.empty())
   {
     //Get a list of locale IDs:
-    typedef std::list<std::string> type_list_ids;
+    typedef std::vector<std::string> type_list_ids;
     type_list_ids list_ids;
 
     const std::string locales_path = "/usr/share/i18n/locales/";
diff --git a/glom/mode_design/iso_codes.h b/glom/mode_design/iso_codes.h
index d6d602c..d8df600 100644
--- a/glom/mode_design/iso_codes.h
+++ b/glom/mode_design/iso_codes.h
@@ -37,7 +37,7 @@ public:
   Glib::ustring m_name;
 };
 
-typedef std::list<Currency> type_list_currencies;
+typedef std::vector<Currency> type_list_currencies;
 type_list_currencies get_list_of_currency_symbols();
 
 class Locale
@@ -47,7 +47,7 @@ public:
   Glib::ustring m_name;
 };
 
-typedef std::list<Locale> type_list_locales;
+typedef std::vector<Locale> type_list_locales;
 type_list_locales get_list_of_locales();
 
 Glib::ustring get_locale_name(const Glib::ustring& locale_id);
diff --git a/glom/mode_design/layout/dialog_choose_field.h b/glom/mode_design/layout/dialog_choose_field.h
index 25af29f..e9391d7 100644
--- a/glom/mode_design/layout/dialog_choose_field.h
+++ b/glom/mode_design/layout/dialog_choose_field.h
@@ -53,7 +53,7 @@ public:
 
   std::shared_ptr<LayoutItem_Field> get_field_chosen() const;
 
-  typedef std::list< std::shared_ptr<LayoutItem_Field> > type_list_field_items;
+  typedef std::vector<std::shared_ptr<LayoutItem_Field>> type_list_field_items;
   type_list_field_items get_fields_chosen() const;
 
 private:
diff --git a/glom/mode_design/layout/dialog_layout_calendar_related.cc 
b/glom/mode_design/layout/dialog_layout_calendar_related.cc
index 8286721..efaa414 100644
--- a/glom/mode_design/layout/dialog_layout_calendar_related.cc
+++ b/glom/mode_design/layout/dialog_layout_calendar_related.cc
@@ -172,7 +172,7 @@ void Dialog_Layout_Calendar_Related::update_ui(bool including_relationship_list)
     }
 
     //Show the field layout
-    //typedef std::list< Glib::ustring > type_listStrings;
+    //typedef std::vector< Glib::ustring > type_listStrings;
 
     m_model_items->clear();
 
diff --git a/glom/mode_design/layout/dialog_layout_details.cc 
b/glom/mode_design/layout/dialog_layout_details.cc
index 98e158e..f99d6fd 100644
--- a/glom/mode_design/layout/dialog_layout_details.cc
+++ b/glom/mode_design/layout/dialog_layout_details.cc
@@ -351,7 +351,7 @@ void Dialog_Layout_Details::init(const Glib::ustring& layout_name, const Glib::u
     }
 
     //Show the field layout
-    //typedef std::list< Glib::ustring > type_listStrings;
+    //typedef std::vector< Glib::ustring > type_listStrings;
 
     m_model_items->clear();
 
diff --git a/glom/mode_design/layout/dialog_layout_list_related.cc 
b/glom/mode_design/layout/dialog_layout_list_related.cc
index edcc8ed..ffaf6ae 100644
--- a/glom/mode_design/layout/dialog_layout_list_related.cc
+++ b/glom/mode_design/layout/dialog_layout_list_related.cc
@@ -227,7 +227,7 @@ void Dialog_Layout_List_Related::update_ui(bool including_relationship_list)
       document->fill_layout_field_details(related_table_name, mapGroups); //Update with full field 
information.
 
       //Show the field layout
-      //typedef std::list< Glib::ustring > type_listStrings;
+      //typedef std::vector< Glib::ustring > type_listStrings;
     }
 
     m_model_items->clear();
diff --git a/glom/mode_design/users/dialog_groups_list.cc b/glom/mode_design/users/dialog_groups_list.cc
index d59a295..f1d303a 100644
--- a/glom/mode_design/users/dialog_groups_list.cc
+++ b/glom/mode_design/users/dialog_groups_list.cc
@@ -149,7 +149,7 @@ void Dialog_GroupsList::set_document(const Glib::ustring& layout, const std::sha
     }
 
     //Show the field layout
-    typedef std::list< Glib::ustring > type_listStrings;
+    typedef std::vector< Glib::ustring > type_listStrings;
 
     m_model_groups->clear();
 
diff --git a/glom/python_embed/glom_python.cc b/glom/python_embed/glom_python.cc
index 518b1f9..8578519 100644
--- a/glom/python_embed/glom_python.cc
+++ b/glom/python_embed/glom_python.cc
@@ -31,7 +31,7 @@
 
 #include "glom_python.h"
 #include <libglom/data_structure/glomconversions.h>
-#include <list>
+#include <vector>
 #include <glib.h> //For g_warning().
 
 #include <iostream>
@@ -39,9 +39,9 @@
 namespace Glom
 {
 
-static std::list<Glib::ustring> ustring_tokenize(const Glib::ustring& msg, const Glib::ustring& separators, 
int maxParts)
+static std::vector<Glib::ustring> ustring_tokenize(const Glib::ustring& msg, const Glib::ustring& 
separators, int maxParts)
 {
-  std::list<Glib::ustring> result;
+  std::vector<Glib::ustring> result;
   Glib::ustring str = msg;
   bool nocount = false;
   if(maxParts == -1)
diff --git a/glom/test_pyembed.cc b/glom/test_pyembed.cc
index 1316887..abd9815 100644
--- a/glom/test_pyembed.cc
+++ b/glom/test_pyembed.cc
@@ -2,11 +2,11 @@
 #include <glib.h> //For g_warning().
 #include <glibmm/ustring.h>
 #include <iostream>
-#include <list>
+#include <vector>
 
-std::list<Glib::ustring> ustring_tokenize(const Glib::ustring& msg, const Glib::ustring& separators, int 
maxParts)
+std::vector<Glib::ustring> ustring_tokenize(const Glib::ustring& msg, const Glib::ustring& separators, int 
maxParts)
 {
-  std::list<Glib::ustring> result;
+  std::vector<Glib::ustring> result;
   Glib::ustring str = msg;
   bool nocount = false;
   if(maxParts == -1)
diff --git a/glom/utility_widgets/dialog_properties.h b/glom/utility_widgets/dialog_properties.h
index b67854e..c3bff78 100644
--- a/glom/utility_widgets/dialog_properties.h
+++ b/glom/utility_widgets/dialog_properties.h
@@ -79,7 +79,7 @@ protected:
 
   bool m_modified;
 
-  //typedef std::list<sigc::connection> type_listConnections; //Store the connections so that we can remove 
them later.
+  //typedef std::vector<sigc::connection> type_listConnections; //Store the connections so that we can 
remove them later.
 };
 
 } //namespace Glom
diff --git a/glom/utility_widgets/flowtable.h b/glom/utility_widgets/flowtable.h
index 15cb7d8..67053b2 100644
--- a/glom/utility_widgets/flowtable.h
+++ b/glom/utility_widgets/flowtable.h
@@ -56,7 +56,7 @@ protected:
 
   void insert(Gtk::Widget* first, Gtk::Widget* second, int index, bool expand);
 
-  typedef std::list<const Gtk::Widget*> type_const_list_widgets;
+  typedef std::vector<const Gtk::Widget*> type_const_list_widgets;
 
   bool on_draw(const Cairo::RefPtr<Cairo::Context>& cr) override;
 
@@ -71,7 +71,7 @@ private:
   Glib::RefPtr<Gdk::Window> m_gdk_window;
 
   //We remember the Boxes so we can delete them when the are no longer used.
-  std::list<Gtk::Box*> m_list_hboxes;
+  std::vector<Gtk::Box*> m_list_hboxes;
 
   type_const_list_widgets m_list_first_widgets;
 };
diff --git a/glom/utility_widgets/test_flowtable.cc b/glom/utility_widgets/test_flowtable.cc
index d769b32..2abd30f 100644
--- a/glom/utility_widgets/test_flowtable.cc
+++ b/glom/utility_widgets/test_flowtable.cc
@@ -41,7 +41,7 @@ void on_drag_data_get_entry(const Glib::RefPtr<Gdk::DragContext>&, Gtk::Selectio
 }
 */
 
-std::list<Gtk::Widget*> vec_child_widgets;
+std::vector<Gtk::Widget*> vec_child_widgets;
 
 static void fill_flowtable(Glom::FlowTable& flowtable)
 {
diff --git a/glom/utils_ui.cc b/glom/utils_ui.cc
index fcf24d3..0dd9425 100644
--- a/glom/utils_ui.cc
+++ b/glom/utils_ui.cc
@@ -254,7 +254,7 @@ Glib::RefPtr<Gdk::Pixbuf> UiUtils::get_pixbuf_for_gda_value(const Gnome::Gda::Va
     /* Note that this is regular binary data, not escaped text representing the binary data: */
     if(buffer_binary && buffer_binary_length)
     {
-      //typedef std::list<Gdk::PixbufFormat> type_list_formats;
+      //typedef std::vector<Gdk::PixbufFormat> type_list_formats;
       //const auto formats = Gdk::Pixbuf::get_formats();
       //std::cout << "Debug: Supported pixbuf formats:\n";
       //for(const auto& item : formats)


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