@@ -249,38 +249,15 @@ void SparsityPattern::sort_row (const BidirectionalIterator begin,
249249 BidirectionalIterator middle,
250250 const BidirectionalIterator end)
251251{
252- if ((begin == middle) || (middle == end)) return ;
253-
254- libmesh_assert_greater (std::distance (begin, middle), 0 );
255- libmesh_assert_greater (std::distance (middle, end), 0 );
256- libmesh_assert (std::unique (begin, middle) == middle);
257- libmesh_assert (std::unique (middle, end) == end);
258-
259- while (middle != end)
260- {
261- BidirectionalIterator
262- b = middle,
263- a = b-1 ;
264-
265- // Bubble-sort the middle value downward
266- while (!(*a < *b)) // *a & *b are less-than comparable, so use <
267- {
268- std::swap (*a, *b);
269-
270- #if defined(__GNUC__) && (__GNUC__ < 4) && !defined(__INTEL_COMPILER)
271- /* Prohibit optimization at this point since gcc 3.3.5 seems
272- to have a bug. */
273- SparsityPattern::_dummy_function ();
252+ // Assure we have the conditions for an inplace_merge
253+ #ifdef DEBUG
254+ libmesh_assert (std::is_sorted (begin, middle));
255+ libmesh_assert (std::is_sorted (middle, end));
274256#endif
257+ libmesh_assert (std::unique (begin, middle) == middle);
258+ libmesh_assert (std::unique (middle, end) == end);
275259
276- if (a == begin) break ;
277-
278- b=a;
279- --a;
280- }
281-
282- ++middle;
283- }
260+ std::inplace_merge (begin, middle, end);
284261
285262 // Assure the algorithm worked if we are in DEBUG mode
286263#ifdef DEBUG
0 commit comments