Skip to content

Commit fc54968

Browse files
committed
Split changeset_ty using iterators instead of loops.
llvm-svn: 171829
1 parent 08281fa commit fc54968

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

llvm/lib/Support/DeltaAlgorithm.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,15 @@ bool DeltaAlgorithm::GetTestResult(const changeset_ty &Changes) {
2727

2828
void DeltaAlgorithm::Split(const changeset_ty &S, changesetlist_ty &Res) {
2929
// FIXME: Allow clients to provide heuristics for improved splitting.
30+
// Get the iterator to the middle.
31+
unsigned N = S.size() / 2;
32+
changeset_ty::iterator middle(S.begin());
33+
std::advance(middle, N);
34+
35+
// Create each vector using the middle as the split.
36+
changeset_ty LHS(S.begin(), middle);
37+
changeset_ty RHS(middle, S.end());
3038

31-
// FIXME: This is really slow.
32-
changeset_ty LHS, RHS;
33-
unsigned idx = 0, N = S.size() / 2;
34-
for (changeset_ty::const_iterator it = S.begin(),
35-
ie = S.end(); it != ie; ++it, ++idx)
36-
((idx < N) ? LHS : RHS).insert(*it);
3739
if (!LHS.empty())
3840
Res.push_back(LHS);
3941
if (!RHS.empty())

0 commit comments

Comments
 (0)