[llvm-commits] [llvm] r171829 - /llvm/trunk/lib/Support/DeltaAlgorithm.cpp

Lenny Maiorani lenny at colorado.edu
Mon Jan 7 17:08:52 PST 2013


Author: lenny
Date: Mon Jan  7 19:08:52 2013
New Revision: 171829

URL: http://llvm.org/viewvc/llvm-project?rev=171829&view=rev
Log:
Split changeset_ty using iterators instead of loops.

Modified:
    llvm/trunk/lib/Support/DeltaAlgorithm.cpp

Modified: llvm/trunk/lib/Support/DeltaAlgorithm.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/DeltaAlgorithm.cpp?rev=171829&r1=171828&r2=171829&view=diff
==============================================================================
--- llvm/trunk/lib/Support/DeltaAlgorithm.cpp (original)
+++ llvm/trunk/lib/Support/DeltaAlgorithm.cpp Mon Jan  7 19:08:52 2013
@@ -27,13 +27,15 @@
 
 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())





More information about the llvm-commits mailing list