diff options
author | Daniel Neuhäuser <ich@danielneuhaeuser.de> | 2010-08-15 21:25:31 +0200 |
---|---|---|
committer | Daniel Neuhäuser <ich@danielneuhaeuser.de> | 2010-08-15 21:25:31 +0200 |
commit | e68b1cacd077f49bafa84b95103945b19910993c (patch) | |
tree | b9cfc949f23612da0d725efdc5413edf047bd96e /sphinx/versioning.py | |
parent | ad5b5c740b3c6af1f6a84af7bfa9f41f6c9c69d2 (diff) | |
download | sphinx-git-e68b1cacd077f49bafa84b95103945b19910993c.tar.gz |
Optimized merging algorithm
Diffstat (limited to 'sphinx/versioning.py')
-rw-r--r-- | sphinx/versioning.py | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/sphinx/versioning.py b/sphinx/versioning.py index 753629042..5f3254554 100644 --- a/sphinx/versioning.py +++ b/sphinx/versioning.py @@ -45,11 +45,17 @@ def merge_doctrees(old, new, condition): old_nodes = old.traverse(condition) new_nodes = new.traverse(condition) ratios = defaultdict(list) + seen = set() for old_node, new_node in product(old_nodes, new_nodes): - ratios[old_node, new_node] = get_ratio(old_node.rawsource, - new_node.rawsource) + if new_node in seen: + continue + ratio = get_ratio(old_node.rawsource, new_node.rawsource) + if ratio == 0: + new_node.uid = old_node.uid + seen.add(new_node) + else: + ratios[old_node, new_node] = ratio ratios = sorted(ratios.iteritems(), key=itemgetter(1)) - seen = set() for (old_node, new_node), ratio in ratios: if new_node in seen: continue |