From b3e4865a998ef3c55d06ada9d86adf6d2b83706c Mon Sep 17 00:00:00 2001
From: Santanu Sinha
Date: Fri, 22 May 2009 01:09:17 +0530
Subject: [PATCH] Replaced STL list with STL vector
In all use cases we almost never push to the middle of a container.
Therefore using an STL vector seems more efficient.
---
src/application/main-window.h | 6 +++---
src/attribute/exif-data.cpp | 2 +-
src/attribute/exif-data.h | 4 ++--
src/attribute/modification-date.cpp | 2 +-
src/attribute/modification-date.h | 2 +-
src/attribute/photo-tag.cpp | 2 +-
src/attribute/photo-tag.h | 1 -
src/attribute/search-basket.cpp | 4 ++--
src/attribute/tag.cpp | 4 ++--
src/attribute/tag.h | 1 -
src/attribute/thumbnail.cpp | 2 +-
src/attribute/thumbnail.h | 4 ++--
src/common/i-storage.h | 4 ----
src/common/photo-search-criteria.h | 1 -
src/common/photo.cpp | 2 +-
src/common/photo.h | 1 -
src/common/types.h | 22 ++++++++++++----------
src/database/database.h | 1 -
src/database/db-object.h | 2 --
src/renderer/thumbnail-view.cpp | 12 ++++++------
20 files changed, 35 insertions(+), 44 deletions(-)
diff --git a/src/application/main-window.h b/src/application/main-window.h
index c16f4fa..a742a79 100644
--- a/src/application/main-window.h
+++ b/src/application/main-window.h
@@ -19,7 +19,7 @@
#ifndef SOLANG_MAIN_WINDOW_H
#define SOLANG_MAIN_WINDOW_H
-#include
+#include
#include
#include
@@ -93,9 +93,9 @@ protected:
bool showStatusBar_;
- std::list dockObjectsLeft_;
+ std::vector dockObjectsLeft_;
- std::list dockObjectsCenter_;
+ std::vector dockObjectsCenter_;
private:
};
diff --git a/src/attribute/exif-data.cpp b/src/attribute/exif-data.cpp
index dadada1..e155b4d 100644
--- a/src/attribute/exif-data.cpp
+++ b/src/attribute/exif-data.cpp
@@ -210,7 +210,7 @@ ExifData &ExifData::operator =(const ExifData &rhs)
}
-void ExifData::insert( std::list &values )
+void ExifData::insert( std::vector &values )
{
values.push_back( Gnome::Gda::Value( get_aperture() ) );
values.push_back( Gnome::Gda::Value( get_shutter_speed() ) );
diff --git a/src/attribute/exif-data.h b/src/attribute/exif-data.h
index c22fde1..8ac8710 100644
--- a/src/attribute/exif-data.h
+++ b/src/attribute/exif-data.h
@@ -21,7 +21,7 @@
#define SOLANG_EXIFDATA_H
#include
-#include
+#include
#include
#include
@@ -120,7 +120,7 @@ class ExifData
return pictureTakenTime_;
}
- void insert( std::list &values );
+ void insert( std::vector &values );
void update( DataModelPtr &model, gint32 row );
void create( DataModelPtr &model, gint32 row );
diff --git a/src/attribute/modification-date.cpp b/src/attribute/modification-date.cpp
index 4819858..30147eb 100644
--- a/src/attribute/modification-date.cpp
+++ b/src/attribute/modification-date.cpp
@@ -22,7 +22,7 @@ ModificationDate::get_query_criteria() const throw()
}
void
-ModificationDate::insert(std::list &values)
+ModificationDate::insert(std::vector &values)
{
values.push_back( Gnome::Gda::Value( get_day() ) );
values.push_back( Gnome::Gda::Value( get_month() ) );
diff --git a/src/attribute/modification-date.h b/src/attribute/modification-date.h
index afc01cc..dfeb99d 100644
--- a/src/attribute/modification-date.h
+++ b/src/attribute/modification-date.h
@@ -150,7 +150,7 @@ class ModificationDate
get_query_criteria() const throw();
void
- insert(std::list &values);
+ insert(std::vector &values);
void
update(DataModelPtr & model, gint32 row) throw(Glib::Error);
diff --git a/src/attribute/photo-tag.cpp b/src/attribute/photo-tag.cpp
index 48cf082..4ef0bce 100644
--- a/src/attribute/photo-tag.cpp
+++ b/src/attribute/photo-tag.cpp
@@ -56,7 +56,7 @@ void PhotoTag::set_photoId_( gint32 photoId )
void PhotoTag::insert(
DataModelPtr &model, gint32 lastIndex) throw(Error)
{
- std::list values;
+ std::vector values;
values.push_back( Gnome::Gda::Value( get_photoId_() ) );
values.push_back( Gnome::Gda::Value( get_tagId_() ) );
diff --git a/src/attribute/photo-tag.h b/src/attribute/photo-tag.h
index b5bd3d3..4fd3b28 100644
--- a/src/attribute/photo-tag.h
+++ b/src/attribute/photo-tag.h
@@ -21,7 +21,6 @@
#define SOLANG_PHOTO_TAG_H
#include
-#include
#include
diff --git a/src/attribute/search-basket.cpp b/src/attribute/search-basket.cpp
index ec96cf5..1086586 100644
--- a/src/attribute/search-basket.cpp
+++ b/src/attribute/search-basket.cpp
@@ -20,7 +20,7 @@
#include "config.h"
#endif // HAVE_CONFIG_H
-#include
+#include
#include
@@ -66,7 +66,7 @@ SearchBasket::SearchBasket() throw() :
gtk_container_add(GTK_CONTAINER(dockItem_),
GTK_WIDGET(scrolledWindow_.gobj()));
- std::list targets;
+ std::vector targets;
targets.push_back(Gtk::TargetEntry("STRING",
Gtk::TARGET_SAME_APP, 0));
targets.push_back(Gtk::TargetEntry("UTF8_STRING",
diff --git a/src/attribute/tag.cpp b/src/attribute/tag.cpp
index b6b60b9..e39d3c7 100644
--- a/src/attribute/tag.cpp
+++ b/src/attribute/tag.cpp
@@ -69,7 +69,7 @@ Tag::set_description(const Glib::ustring & description) throw()
void Tag::insert(
DataModelPtr &model, gint32 lastIndex) throw(Error)
{
- std::list values;
+ std::vector values;
values.push_back( Gnome::Gda::Value( lastIndex + 1 ) ); //tagid
std::cout<<"Tagid= "< "< values;
+ std::vector values;
values.push_back( Gnome::Gda::Value( get_tag_id() ) );
values.push_back( Gnome::Gda::Value( get_name() ) );
values.push_back( Gnome::Gda::Value( get_description() ) );
diff --git a/src/attribute/tag.h b/src/attribute/tag.h
index 3948aee..616a59f 100644
--- a/src/attribute/tag.h
+++ b/src/attribute/tag.h
@@ -21,7 +21,6 @@
#define SOLANG_TAG_H
#include
-#include
#include
diff --git a/src/attribute/thumbnail.cpp b/src/attribute/thumbnail.cpp
index 2399f74..c41d4fa 100644
--- a/src/attribute/thumbnail.cpp
+++ b/src/attribute/thumbnail.cpp
@@ -289,7 +289,7 @@ Thumbnail::generate_using_gdkpixbuf(const Glib::ustring & path,
return;
}
-void Thumbnail::insert( std::list &values )
+void Thumbnail::insert( std::vector &values )
{
values.push_back(Gnome::Gda::Value( get_path() ) );
values.push_back(Gnome::Gda::Value( get_resolution().get_x()));
diff --git a/src/attribute/thumbnail.h b/src/attribute/thumbnail.h
index 91c6206..2cc91b9 100644
--- a/src/attribute/thumbnail.h
+++ b/src/attribute/thumbnail.h
@@ -20,7 +20,7 @@
#ifndef SOLANG_THUMBNAIL_H
#define SOLANG_THUMBNAIL_H
-#include
+#include
#include
#include
@@ -149,7 +149,7 @@ class Thumbnail
const Photo &photo) throw(Error);
void
- insert(std::list &values);
+ insert(std::vector &values);
void
update(DataModelPtr & model, gint32 row) throw(Glib::Error);
diff --git a/src/common/i-storage.h b/src/common/i-storage.h
index 7d5e054..e2053a2 100644
--- a/src/common/i-storage.h
+++ b/src/common/i-storage.h
@@ -20,8 +20,6 @@
#ifndef SOLANG_I_STORAGE_H
#define SOLANG_I_STORAGE_H
-#include
-
#include
#include "error.h"
@@ -77,8 +75,6 @@ class IStorage :
private:
};
-typedef std::list IStorageList;
-
} // namespace Solang
#endif // SOLANG_STORAGE_H
diff --git a/src/common/photo-search-criteria.h b/src/common/photo-search-criteria.h
index 810da7e..bae626e 100644
--- a/src/common/photo-search-criteria.h
+++ b/src/common/photo-search-criteria.h
@@ -20,7 +20,6 @@
#ifndef SOLANG_PHOTO_SEARCH_CRITERIA_H
#define SOLANG_PHOTO_SEARCH_CRITERIA_H
-#include
#include
#include
diff --git a/src/common/photo.cpp b/src/common/photo.cpp
index 7b9e973..f6520b8 100644
--- a/src/common/photo.cpp
+++ b/src/common/photo.cpp
@@ -106,7 +106,7 @@ Glib::ustring Photo::getCreateSQL() throw(Error)
void Photo::insert( DataModelPtr &model, gint32 lastIndex) throw(Error)
{
- std::list values;
+ std::vector values;
values.push_back( Gnome::Gda::Value( lastIndex + 1 ) ); //photoid
values.push_back( Gnome::Gda::Value( get_uri() ) );
diff --git a/src/common/photo.h b/src/common/photo.h
index 2369d3b..4e96016 100644
--- a/src/common/photo.h
+++ b/src/common/photo.h
@@ -20,7 +20,6 @@
#ifndef SOLANG_PHOTO_H
#define SOLANG_PHOTO_H
-#include
#include
#include
diff --git a/src/common/types.h b/src/common/types.h
index 082a9bd..b741441 100644
--- a/src/common/types.h
+++ b/src/common/types.h
@@ -41,6 +41,7 @@ typedef Database * DatabasePtr;
class DBObject;
typedef std::tr1::shared_ptr ConstDBObjectPtr;
typedef std::tr1::shared_ptr DBObjectPtr;
+typedef std::vector DBObjectList;
class DBTable;
typedef std::tr1::shared_ptr ConstDBTablePtr;
@@ -48,13 +49,13 @@ typedef std::tr1::shared_ptr DBTablePtr;
class ExifDataKey;
typedef std::tr1::shared_ptr ExifDataKeyPtr;
-typedef std::list ExifDataKeyList;
+typedef std::vector ExifDataKeyList;
class IPhotoDestination;
typedef std::tr1::shared_ptr
ConstIPhotoDestinationPtr;
typedef std::tr1::shared_ptr IPhotoDestinationPtr;
-typedef std::list IPhotoDestinationList;
+typedef std::vector IPhotoDestinationList;
class ExifData;
typedef std::tr1::shared_ptr ExifDataPtr;
@@ -62,27 +63,27 @@ typedef std::tr1::shared_ptr ExifDataPtr;
class IPhotoSource;
typedef std::tr1::shared_ptr ConstIPhotoSourcePtr;
typedef std::tr1::shared_ptr IPhotoSourcePtr;
-typedef std::list IPhotoSourceList;
+typedef std::vector IPhotoSourceList;
class IPlugin;
typedef std::tr1::shared_ptr ConstIPluginPtr;
typedef std::tr1::shared_ptr IPluginPtr;
class DatePhotoInfo;
-typedef std::list DatePhotoInfoList;
+typedef std::vector DatePhotoInfoList;
class Photo;
typedef std::tr1::shared_ptr ConstPhotoPtr;
typedef std::tr1::shared_ptr PhotoPtr;
typedef Photo * UnrefPhotoPtr;
-typedef std::list PhotoList;
+typedef std::vector PhotoList;
class PhotoSearchCriteria;
typedef std::tr1::shared_ptr
ConstPhotoSearchCriteriaPtr;
typedef std::tr1::shared_ptr
PhotoSearchCriteriaPtr;
-typedef std::list PhotoSearchCriteriaList;
+typedef std::vector PhotoSearchCriteriaList;
class ProgressDialog;
typedef Glib::RefPtr ConstProgressDialogPtr;
@@ -96,16 +97,17 @@ typedef std::tr1::shared_ptr ProgressObserverPtr;
class Renderer;
typedef std::tr1::shared_ptr ConstRendererPtr;
typedef std::tr1::shared_ptr RendererPtr;
-typedef std::list RendererList;
+typedef std::vector RendererList;
class IStorage;
typedef std::tr1::shared_ptr ConstIStoragePtr;
typedef std::tr1::shared_ptr IStoragePtr;
+typedef std::vector IStorageList;
class Tag;
typedef std::tr1::shared_ptr ConstTagPtr;
typedef std::tr1::shared_ptr TagPtr;
-typedef std::list TagList;
+typedef std::vector TagList;
class Thumbnail;
typedef std::tr1::shared_ptr ConstThumbnailPtr;
@@ -132,14 +134,14 @@ typedef Glib::RefPtr MenuPtr;
class SearchCriterionSource;
typedef SearchCriterionSource * SearchCriterionSourcePtr;
-typedef std::list SearchCriterionSourceList;
+typedef std::vector SearchCriterionSourceList;
typedef Glib::RefPtr ConstTreeModelPtr;
typedef Glib::RefPtr TreeModelPtr;
typedef Glib::RefPtr ConstTreePathPtr;
typedef Glib::RefPtr TreePathPtr;
-typedef std::list TreePathList;
+typedef std::vector TreePathList;
typedef Glib::RefPtr ConstUIManagerPtr;
typedef Glib::RefPtr UIManagerPtr;
diff --git a/src/database/database.h b/src/database/database.h
index 5856ba7..58f9fb6 100644
--- a/src/database/database.h
+++ b/src/database/database.h
@@ -20,7 +20,6 @@
#ifndef SOLANG_DATABASE_H
#define SOLANG_DATABASE_H
-#include
#include
#include
diff --git a/src/database/db-object.h b/src/database/db-object.h
index 4588c4a..5f79da7 100644
--- a/src/database/db-object.h
+++ b/src/database/db-object.h
@@ -82,8 +82,6 @@ class DBObject :
};
-typedef std::list DBObjectList;
-
inline gint32 DBObject::get_row_() const throw()
{
return row_;
diff --git a/src/renderer/thumbnail-view.cpp b/src/renderer/thumbnail-view.cpp
index e59683b..52425f4 100644
--- a/src/renderer/thumbnail-view.cpp
+++ b/src/renderer/thumbnail-view.cpp
@@ -20,7 +20,7 @@
#include "config.h"
#endif // HAVE_CONFIG_H
-#include
+#include
#include
#include "browser-model-column-record.h"
@@ -130,8 +130,8 @@ ThumbnailView::configure() throw()
rendererInfo_.property_height().set_value(20);
rendererInfo_.property_rise().set_value(2);
- std::list targets;
- targets.push_back(Gtk::TargetEntry("text/uri-list",
+ std::vector targets;
+ targets.push_back(Gtk::TargetEntry("text/uri-vector",
Gtk::TARGET_OTHER_APP, 0));
enable_model_drag_source(targets, Gdk::MODIFIER_MASK,
Gdk::ACTION_COPY);
@@ -162,8 +162,8 @@ PhotoList
ThumbnailView::get_selected_photos() throw()
{
PhotoList photos;
- std::list items = get_selected_items();
- std::list::iterator iter;
+ std::vector items = get_selected_items();
+ std::vector::iterator iter;
for (iter = items.begin(); items.end() != iter; iter++)
{
@@ -214,7 +214,7 @@ ThumbnailView::on_drag_data_get_cb(const DragContextPtr & drag_context,
PhotoList photos = get_selected_photos();
PhotoList::iterator photo_iter;
- std::list uris;
+ std::vector uris;
for (photo_iter = photos.begin(); photos.end() != photo_iter;
photo_iter++)
--
1.6.2.1