summaryrefslogtreecommitdiff
path: root/lib/Support/DeltaAlgorithm.cpp
diff options
context:
space:
mode:
authorLenny Maiorani <lenny@colorado.edu>2013-01-08 01:08:52 +0000
committerLenny Maiorani <lenny@colorado.edu>2013-01-08 01:08:52 +0000
commitc09b4c00aaab25676ca903a4e137ac19ccb7d637 (patch)
tree9c75af3eeacaafa9097e74e5d96c25127fa57e35 /lib/Support/DeltaAlgorithm.cpp
parent0fecdfb7c44aee85e78e0ba6e9547b702bc64c4a (diff)
downloadllvm-c09b4c00aaab25676ca903a4e137ac19ccb7d637.tar.gz
llvm-c09b4c00aaab25676ca903a4e137ac19ccb7d637.tar.bz2
llvm-c09b4c00aaab25676ca903a4e137ac19ccb7d637.tar.xz
Split changeset_ty using iterators instead of loops.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@171829 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Support/DeltaAlgorithm.cpp')
-rw-r--r--lib/Support/DeltaAlgorithm.cpp14
1 files changed, 8 insertions, 6 deletions
diff --git a/lib/Support/DeltaAlgorithm.cpp b/lib/Support/DeltaAlgorithm.cpp
index 9e52874de8..a1e3311497 100644
--- a/lib/Support/DeltaAlgorithm.cpp
+++ b/lib/Support/DeltaAlgorithm.cpp
@@ -27,13 +27,15 @@ bool DeltaAlgorithm::GetTestResult(const changeset_ty &Changes) {
void DeltaAlgorithm::Split(const changeset_ty &S, changesetlist_ty &Res) {
// FIXME: Allow clients to provide heuristics for improved splitting.
+ // Get the iterator to the middle.
+ unsigned N = S.size() / 2;
+ changeset_ty::iterator middle(S.begin());
+ std::advance(middle, N);
+
+ // Create each vector using the middle as the split.
+ changeset_ty LHS(S.begin(), middle);
+ changeset_ty RHS(middle, S.end());
- // FIXME: This is really slow.
- changeset_ty LHS, RHS;
- unsigned idx = 0, N = S.size() / 2;
- for (changeset_ty::const_iterator it = S.begin(),
- ie = S.end(); it != ie; ++it, ++idx)
- ((idx < N) ? LHS : RHS).insert(*it);
if (!LHS.empty())
Res.push_back(LHS);
if (!RHS.empty())