banshee r5198 - in trunk/banshee: . src/Libraries/Mono.Data.Sqlite/Mono.Data.Sqlite



Author: gburt
Date: Thu Apr  9 00:11:45 2009
New Revision: 5198
URL: http://svn.gnome.org/viewvc/banshee?rev=5198&view=rev

Log:
2009-04-08  Gabriel Burt  <gabriel burt gmail com>

	* src/Libraries/Mono.Data.Sqlite/Mono.Data.Sqlite/SQLite3.cs:
	* src/Libraries/Mono.Data.Sqlite/Mono.Data.Sqlite/SQLiteBase.cs:
	* src/Libraries/Mono.Data.Sqlite/Mono.Data.Sqlite/SQLiteCommand.cs:
	* src/Libraries/Mono.Data.Sqlite/Mono.Data.Sqlite/SQLiteConvert.cs:
	* src/Libraries/Mono.Data.Sqlite/Mono.Data.Sqlite/SQLiteDataReader.cs:
	Performance fixes ported from upstream System.Data.Sqlite, making SqliteType
	a class (not struct) and avoid unnecessary calls to TypeNameToDbType.

Modified:
   trunk/banshee/ChangeLog
   trunk/banshee/src/Libraries/Mono.Data.Sqlite/Mono.Data.Sqlite/SQLite3.cs
   trunk/banshee/src/Libraries/Mono.Data.Sqlite/Mono.Data.Sqlite/SQLiteBase.cs
   trunk/banshee/src/Libraries/Mono.Data.Sqlite/Mono.Data.Sqlite/SQLiteCommand.cs
   trunk/banshee/src/Libraries/Mono.Data.Sqlite/Mono.Data.Sqlite/SQLiteConvert.cs
   trunk/banshee/src/Libraries/Mono.Data.Sqlite/Mono.Data.Sqlite/SQLiteDataReader.cs

Modified: trunk/banshee/src/Libraries/Mono.Data.Sqlite/Mono.Data.Sqlite/SQLite3.cs
==============================================================================
--- trunk/banshee/src/Libraries/Mono.Data.Sqlite/Mono.Data.Sqlite/SQLite3.cs	(original)
+++ trunk/banshee/src/Libraries/Mono.Data.Sqlite/Mono.Data.Sqlite/SQLite3.cs	Thu Apr  9 00:11:45 2009
@@ -633,7 +633,7 @@
     /// <param name="index">The column index to retrieve</param>
     /// <param name="typ">The type of data contained in the column.  If Uninitialized, this function will retrieve the datatype information.</param>
     /// <returns>Returns the data in the column</returns>
-    internal override object GetValue(SqliteStatement stmt, int index, ref SqliteType typ)
+    internal override object GetValue(SqliteStatement stmt, int index, SqliteType typ)
     {
       if (typ.Affinity == 0) typ = SqliteConvert.ColumnToType(stmt, index);
       if (IsNull(stmt, index)) return DBNull.Value;

Modified: trunk/banshee/src/Libraries/Mono.Data.Sqlite/Mono.Data.Sqlite/SQLiteBase.cs
==============================================================================
--- trunk/banshee/src/Libraries/Mono.Data.Sqlite/Mono.Data.Sqlite/SQLiteBase.cs	(original)
+++ trunk/banshee/src/Libraries/Mono.Data.Sqlite/Mono.Data.Sqlite/SQLiteBase.cs	Thu Apr  9 00:11:45 2009
@@ -179,7 +179,7 @@
 
     internal abstract int GetLastInsertRowId ();
     
-    internal abstract object GetValue(SqliteStatement stmt, int index, ref SqliteType typ);
+    internal abstract object GetValue(SqliteStatement stmt, int index, SqliteType typ);
 
     protected virtual void Dispose(bool bDisposing)
     {

Modified: trunk/banshee/src/Libraries/Mono.Data.Sqlite/Mono.Data.Sqlite/SQLiteCommand.cs
==============================================================================
--- trunk/banshee/src/Libraries/Mono.Data.Sqlite/Mono.Data.Sqlite/SQLiteCommand.cs	(original)
+++ trunk/banshee/src/Libraries/Mono.Data.Sqlite/Mono.Data.Sqlite/SQLiteCommand.cs	Thu Apr  9 00:11:45 2009
@@ -587,7 +587,7 @@
 
         if (_cnn._sql.Step(stmt) == true && ret == null)
         {
-          ret = _cnn._sql.GetValue(stmt, 0, ref typ);
+          ret = _cnn._sql.GetValue(stmt, 0, typ);
         }
         _cnn._sql.Reset(stmt);
       }

Modified: trunk/banshee/src/Libraries/Mono.Data.Sqlite/Mono.Data.Sqlite/SQLiteConvert.cs
==============================================================================
--- trunk/banshee/src/Libraries/Mono.Data.Sqlite/Mono.Data.Sqlite/SQLiteConvert.cs	(original)
+++ trunk/banshee/src/Libraries/Mono.Data.Sqlite/Mono.Data.Sqlite/SQLiteConvert.cs	Thu Apr  9 00:11:45 2009
@@ -113,7 +113,7 @@
   /// <summary>
   /// Struct used internally to determine the datatype of a column in a resultset
   /// </summary>
-  internal struct SqliteType
+  internal class SqliteType
   {
     /// <summary>
     /// The DbType of the column, or DbType.Object if it cannot be determined
@@ -378,7 +378,7 @@
     /// <returns>Returns a SqliteType struct</returns>
     internal static SqliteType ColumnToType(SqliteStatement stmt, int i)
     {
-      SqliteType typ;
+      SqliteType typ = new SqliteType ();
 
       typ.Type = TypeNameToDbType(stmt._sql.ColumnType(stmt, i, out typ.Affinity));
 

Modified: trunk/banshee/src/Libraries/Mono.Data.Sqlite/Mono.Data.Sqlite/SQLiteDataReader.cs
==============================================================================
--- trunk/banshee/src/Libraries/Mono.Data.Sqlite/Mono.Data.Sqlite/SQLiteDataReader.cs	(original)
+++ trunk/banshee/src/Libraries/Mono.Data.Sqlite/Mono.Data.Sqlite/SQLiteDataReader.cs	Thu Apr  9 00:11:45 2009
@@ -836,7 +836,7 @@
 #endif
       SqliteType typ = GetSqliteType(i);
       typ.Affinity = _activeStatement._sql.ColumnAffinity(_activeStatement, i);
-      return _activeStatement._sql.GetValue(_activeStatement, i, ref typ);
+      return _activeStatement._sql.GetValue(_activeStatement, i, typ);
     }
 
     /// <summary>
@@ -986,11 +986,24 @@
     /// <returns>A SqliteType structure</returns>
     private SqliteType GetSqliteType(int i)
     {
+      SqliteType typ;
+
+      // Initialize the field types array if not already initialized
       if (_fieldTypeArray == null) _fieldTypeArray = new SqliteType[VisibleFieldCount];
 
-      if (_fieldTypeArray[i].Affinity == TypeAffinity.Uninitialized || _fieldTypeArray[i].Affinity == TypeAffinity.Null)
-        _fieldTypeArray[i].Type = SqliteConvert.TypeNameToDbType(_activeStatement._sql.ColumnType(_activeStatement, i, out _fieldTypeArray[i].Affinity));
-      return _fieldTypeArray[i];
+      // Initialize this column's field type instance
+      if (_fieldTypeArray[i] == null) _fieldTypeArray[i] = new SqliteType();
+
+      typ = _fieldTypeArray[i];
+
+      // If not initialized, then fetch the declared column datatype and attempt to convert it 
+      // to a known DbType.
+      if (typ.Affinity == TypeAffinity.Uninitialized)
+        typ.Type = SqliteConvert.TypeNameToDbType(_activeStatement._sql.ColumnType(_activeStatement, i, out typ.Affinity));
+      else
+        typ.Affinity = _activeStatement._sql.ColumnAffinity(_activeStatement, i);
+
+      return typ;
     }
 
     /// <summary>



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