core: delegate exec in special cases
authorJens Georg <mail@jensge.org>
Wed, 30 Sep 2009 11:04:51 +0000 (13:04 +0200)
committerZeeshan Ali (Khattak) <zeeshanak@gnome.org>
Sat, 24 Oct 2009 13:43:24 +0000 (16:43 +0300)
if there's nothing to bind and noone to callback, just forward to SQLite

src/rygel/rygel-database.vala

index 706b97f..5483a46 100644 (file)
@@ -51,12 +51,17 @@ internal class Rygel.Database : Object {
                      RowCallback?  callback = null) throws DatabaseError {
         var t = new Timer ();
         int rc;
-        var statement = prepare_statement (sql, values);
-        while ((rc = statement.step ()) == Sqlite.ROW) {
-            if (callback != null) {
-                if (!callback (statement)) {
-                    rc = Sqlite.DONE;
-                    break;
+
+        if (values == null && callback == null) {
+            rc = this.db.exec (sql);
+        } else {
+            var statement = prepare_statement (sql, values);
+            while ((rc = statement.step ()) == Sqlite.ROW) {
+                if (callback != null) {
+                    if (!callback (statement)) {
+                        rc = Sqlite.DONE;
+                        break;
+                    }
                 }
             }
         }