#
# patch "ChangeLog"
# from [237c4f810a60e8085f044b7ef7af10b7ef5845a0]
# to [33d2af6dcdcf261a25b3bd62d38f4ab7b518d9ac]
#
# patch "commands.cc"
# from [afab75c11da6170ea4a46e843f53cde5c8fbc145]
# to [3bb4a480d7b67398096823f00743f43d6eb1404a]
#
# patch "interner.hh"
# from [57c97faa357c9664fa8c3e457f12a97db9852ed7]
# to [31d3f27219df930763472894aa9bc653f533c077]
#
# patch "pcdv.cc"
# from [57f77609eec9cfaf8e2534644d3ca32dffd2d21c]
# to [344d7cbbc185228a0d22d2a3db6c94bf85d828f0]
#
# patch "pcdv.hh"
# from [4e541a7ea48ee65f3510dcd58c7e1a4b173cfe15]
# to [144f8837c224ee7a70d28b9bda553ed00da7e4b5]
#
===============================================
--- ChangeLog 237c4f810a60e8085f044b7ef7af10b7ef5845a0
+++ ChangeLog 33d2af6dcdcf261a25b3bd62d38f4ab7b518d9ac
@@ -1,3 +1,11 @@
+2005-07-09 Timothy Brownawell
+
+ * pcdv.{cc,hh}: More speedups; use interners to work with ints instead
+ of strings. Data structure changes.
+ * commands.cc (CMD(pcdv)): Don't keep file_state for unneded revisions.
+ Gets rid of memory usage problems.
+ * interner.hh (interner::intern): Make slightly faster.
+
2005-07-01 Timothy Brownawell
* pcdv.cc: Various speedups.
===============================================
--- commands.cc afab75c11da6170ea4a46e843f53cde5c8fbc145
+++ commands.cc 3bb4a480d7b67398096823f00743f43d6eb1404a
@@ -3827,6 +3827,10 @@
if (args.size() != 3)
throw usage(name);
+ revision_id left, right;
+ complete(app, idx(args, 0)(), left);
+ complete(app, idx(args, 1)(), right);
+
typedef std::multimap::iterator gi;
typedef std::map > >::iterator pi;
std::multimap graph;
@@ -3834,6 +3838,7 @@
std::set leaves;
app.db.get_revision_ids(leaves);
std::map > > parents;
+ std::map child_count;
for (gi i = graph.begin(); i != graph.end(); ++i)
parents.insert(std::make_pair(i->first,
std::make_pair(0, vector())));
@@ -3848,8 +3853,12 @@
for (pi i = parents.begin(); i != parents.end(); ++i)
if(i->second.first == 0)
roots.push_back(i->first);
+
+ ticker count("Revs in weave", "R", 1);
+ ticker lines("Lines in weave", "L", 1);
+
map files;
- file_state empty = file_state(vector(), string());
+ file_state empty;
std::set heads;
file_state p(empty);
while (!roots.empty())
@@ -3873,27 +3882,42 @@
p = i->second.mash(j->second);
}
vector contents(get_file(roots.front(), idx(args, 2)(), app));
- files.insert(std::make_pair(roots.front(),p.resolve(contents, roots.front().inner()())));
+ string r(roots.front().inner()());
+ files.insert(std::make_pair(roots.front(),p.resolve(contents, r)));
+
+ ++count;
+ lines += (empty.weave->size() - lines.ticks);
+
heads.insert(roots.front());
for (vector::const_iterator i = ps.begin();
i != ps.end(); ++i)
- heads.erase(*i);
- for(gi i = graph.lower_bound(roots.front());
- i != graph.upper_bound(roots.front()); i++)
- if(--(parents[i->second].first) == 0)
- roots.push_back(i->second);
+ {
+ heads.erase(*i);
+ if (--child_count[*i] == 0
+ && left.inner()() != i->inner()()
+ && right.inner()() != i->inner()())
+ files.erase(*i);
+ }
+ int children = 0;
+ for (gi i = graph.lower_bound(roots.front());
+ i != graph.upper_bound(roots.front()); i++)
+ {
+ if (--(parents[i->second].first) == 0)
+ roots.push_back(i->second);
+ ++children;
+ }
+ child_count.insert(make_pair(roots.front(), children));
graph.erase(roots.front());
leaves.erase(roots.front());
roots.pop_front();
}
- revision_id left, right;
- complete(app, idx(args, 0)(), left);
- complete(app, idx(args, 1)(), right);
+
map::iterator l = files.find(left);
- N(l != files.end(), F("Not found."));
+ N(l != files.end(), F("Not found: %s.") % left);
map::iterator r = files.find(right);
- N(r != files.end(), F("Not found."));
+ N(r != files.end(), F("Not found: %s.") % right);
vector result(l->second.conflict(r->second));
+ P(F(""));
show_conflict(consolidate(result));
}
===============================================
--- interner.hh 57c97faa357c9664fa8c3e457f12a97db9852ed7
+++ interner.hh 31d3f27219df930763472894aa9bc653f533c077
@@ -52,18 +52,15 @@
}
T intern(std::string const & s, bool & is_new)
{
- is_new = false;
- typename hmap::const_iterator i = fwd.find(s);
- if (i == fwd.end())
- {
- is_new = true;
- T t = rev.size();
- fwd.insert(make_pair(s, t));
- rev.push_back(s);
- return t;
- }
- else
- return i->second;
+ std::pair res;
+ T t = rev.size();
+ // if fwd already contains an entry with key s, this just finds
+ // that and returns it
+ res = fwd.insert(make_pair(s, t));
+ is_new = res.second;
+ if (is_new)
+ rev.push_back(s);
+ return res.first->second;
}
};
===============================================
--- pcdv.cc 57f77609eec9cfaf8e2534644d3ca32dffd2d21c
+++ pcdv.cc 344d7cbbc185228a0d22d2a3db6c94bf85d828f0
@@ -1,17 +1,20 @@
#include
#include