[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Monotone-commits-diffs] net.venge.monotone: 7052f486274676039b74349ab3
From: |
code |
Subject: |
[Monotone-commits-diffs] net.venge.monotone: 7052f486274676039b74349ab3eca84e7ba09323 |
Date: |
Sat, 22 Jan 2011 19:25:35 GMT |
revision: 7052f486274676039b74349ab3eca84e7ba09323
date: 2011-01-22T19:23:38
author: Richard Hopkins
branch: net.venge.monotone
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 [fda60d19a671b5d7467c3a19450c700886a1c8f8]
old_revision [4f505ed0817cef6a34e1cc404b0511426a15fef9]
patch "database.cc"
from [9b6b20b6b342f4294e9e9d6cfd42d228db7ad18f]
to [ecdc5c4bc826e966f06d310e35115e41f783df92]
============================================================
--- database.cc 9b6b20b6b342f4294e9e9d6cfd42d228db7ad18f
+++ database.cc ecdc5c4bc826e966f06d310e35115e41f783df92
@@ -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
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Monotone-commits-diffs] net.venge.monotone: 7052f486274676039b74349ab3eca84e7ba09323,
code <=