]> git.ktnx.net Git - mobile-ledger.git/commitdiff
minor optimization in getting next generation
authorDamyan Ivanov <dam+mobileledger@ktnx.net>
Fri, 26 Mar 2021 16:53:58 +0000 (18:53 +0200)
committerDamyan Ivanov <dam+mobileledger@ktnx.net>
Fri, 26 Mar 2021 16:53:58 +0000 (18:53 +0200)
app/src/main/java/net/ktnx/mobileledger/model/MobileLedgerProfile.java

index a7a6eeab98749876188044cf200c47ee8e1dcb0b..6f70bda5498d283aa5d62b5ba346d34ec1806b2a 100644 (file)
@@ -547,27 +547,22 @@ public final class MobileLedgerProfile {
         this.themeHue = themeHue;
     }
     public int getNextTransactionsGeneration(SQLiteDatabase db) {
-        int generation = 1;
         try (Cursor c = db.rawQuery(
                 "SELECT generation FROM transactions WHERE profile_id=? LIMIT 1",
                 new String[]{String.valueOf(id)}))
         {
-            if (c.moveToFirst()) {
-                generation = c.getInt(0) + 1;
-            }
+            if (c.moveToFirst())
+                return c.getInt(0) + 1;
         }
-        return generation;
+        return 1;
     }
     private int getNextAccountsGeneration(SQLiteDatabase db) {
-        int generation = 1;
         try (Cursor c = db.rawQuery("SELECT generation FROM accounts WHERE profile_id=? LIMIT 1",
-                new String[]{String.valueOf(id)}))
-        {
-            if (c.moveToFirst()) {
-                generation = c.getInt(0) + 1;
-            }
+                new String[]{String.valueOf(id)})) {
+            if (c.moveToFirst())
+                return c.getInt(0) + 1;
         }
-        return generation;
+        return 1;
     }
     private void deleteNotPresentAccounts(SQLiteDatabase db, int generation) {
         Logger.debug("db/benchmark", "Deleting obsolete accounts");