monotone-commits-diffs
[Top][All Lists]
Advanced

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

[Monotone-commits-diffs] net.venge.monotone.rich.monotone-0.99: 52efdbf


From: code
Subject: [Monotone-commits-diffs] net.venge.monotone.rich.monotone-0.99: 52efdbfabcc76d052bb125093c61086bf5f8874d
Date: Mon, 21 Mar 2011 14:40:07 +0100 (CET)

revision:            52efdbfabcc76d052bb125093c61086bf5f8874d
date:                2011-01-21T21:20:23
author:              Richard Hopkins
branch:              net.venge.monotone.rich.monotone-0.99
changelog:
database::get_var and var_exists now only ask for a single row

Previously they called get_vars which brought back the whole table
and like the FIXME said, it's not ideal but doesn't really matter
as theres only a handful of entries usually in db_vars.

Having said that, this patch removes a FIXME from the tree and has
the potential to improve performance ever so slightly.

manifest:
format_version "1"

new_manifest [906745eda55152a0c71e7679c915692cce41b30b]

old_revision [a92afea09d497594da69317ef9c661807ef38b2a]

patch "database.cc"
 from [8bfff559a0894259fe3668294bd3906ae837129b]
   to [0e6c4d3b44354f925ccbb6ee7533297251ff1170]
============================================================
--- database.cc	8bfff559a0894259fe3668294bd3906ae837129b
+++ database.cc	0e6c4d3b44354f925ccbb6ee7533297251ff1170
@@ -4497,22 +4497,29 @@ database::get_var(var_key const & key, v
 void
 database::get_var(var_key const & key, var_value & value)
 {
-  // FIXME: sillyly inefficient.  Doesn't really matter, though.
-  map<var_key, var_value> vars;
-  get_vars(vars);
-  map<var_key, var_value>::const_iterator i = vars.find(key);
-  I(i != vars.end());
-  value = i->second;
+  results res;
+  imp->fetch(res, one_col, any_rows, 
+             query("SELECT value FROM db_vars "
+                   "WHERE domain = ? AND name = ?")
+                   % text(key.first())
+                   % blob(key.second()));
+  I(res.size() == 1);
+  var_value dbvalue(res[0][0], origin::database);
+  value = dbvalue;
 }
 
 bool
 database::var_exists(var_key const & key)
 {
-  // FIXME: sillyly inefficient.  Doesn't really matter, though.
-  map<var_key, var_value> vars;
-  get_vars(vars);
-  map<var_key, var_value>::const_iterator i = vars.find(key);
-  return i != vars.end();
+  results res;
+  imp->fetch(res, one_col, any_rows,
+             query("SELECT 1 "
+                   "WHERE EXISTS("
+                   "  SELECT 1 FROM db_vars "
+                   "  WHERE domain = ? AND name = ?)")
+                   % text(key.first())
+                   % blob(key.second()));
+  return ! res.empty();
 }
 
 void

reply via email to

[Prev in Thread] Current Thread [Next in Thread]