aboutsummaryrefslogtreecommitdiff
path: root/src/libstore/db.cc
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2004-06-20 13:37:51 +0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2004-06-20 13:37:51 +0000
commit85ae78176520fbba0420e5dc772d76144b564605 (patch)
tree17d0b75cf1d6cd00e5c9ce1e61c4ecbdf55b885a /src/libstore/db.cc
parent23bb902d1f65831d74a33051fdb8c0230b7a3e37 (diff)
* Refactoring.
Diffstat (limited to 'src/libstore/db.cc')
-rw-r--r--src/libstore/db.cc43
1 files changed, 2 insertions, 41 deletions
diff --git a/src/libstore/db.cc b/src/libstore/db.cc
index d2a002638..8c0678d0e 100644
--- a/src/libstore/db.cc
+++ b/src/libstore/db.cc
@@ -337,32 +337,9 @@ bool Database::queryStrings(const Transaction & txn, TableId table,
const string & key, Strings & data)
{
string d;
-
if (!queryString(txn, table, key, d))
return false;
-
- string::iterator it = d.begin();
-
- while (it != d.end()) {
-
- if (it + 4 > d.end())
- throw Error(format("short db entry: `%1%'") % d);
-
- unsigned int len;
- len = (unsigned char) *it++;
- len |= ((unsigned char) *it++) << 8;
- len |= ((unsigned char) *it++) << 16;
- len |= ((unsigned char) *it++) << 24;
-
- if (it + len > d.end())
- throw Error(format("short db entry: `%1%'") % d);
-
- string s;
- while (len--) s += *it++;
-
- data.push_back(s);
- }
-
+ data = unpackStrings(d);
return true;
}
@@ -383,23 +360,7 @@ void Database::setString(const Transaction & txn, TableId table,
void Database::setStrings(const Transaction & txn, TableId table,
const string & key, const Strings & data)
{
- string d;
-
- for (Strings::const_iterator it = data.begin();
- it != data.end(); it++)
- {
- string s = *it;
- unsigned int len = s.size();
-
- d += len & 0xff;
- d += (len >> 8) & 0xff;
- d += (len >> 16) & 0xff;
- d += (len >> 24) & 0xff;
-
- d += s;
- }
-
- setString(txn, table, key, d);
+ setString(txn, table, key, packStrings(data));
}