Skip to content

Commit f94187f

Browse files
committed
---
yaml --- r: 233590 b: refs/heads/beta c: a54b91f h: refs/heads/master v: v3
1 parent 9f24f6d commit f94187f

File tree

2 files changed

+13
-14
lines changed

2 files changed

+13
-14
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ refs/tags/0.9: 36870b185fc5f5486636d4515f0e22677493f225
2323
refs/tags/0.10: ac33f2b15782272ae348dbd7b14b8257b2148b5a
2424
refs/tags/0.11.0: e1247cb1d0d681be034adb4b558b5a0c0d5720f9
2525
refs/tags/0.12.0: f0c419429ef30723ceaf6b42f9b5a2aeb5d2e2d1
26-
refs/heads/beta: b247402666d1c149005de1d341f3fa49fb2943a4
26+
refs/heads/beta: a54b91ff5bb1672ba0dc83a5ead0e599723714f6
2727
refs/tags/1.0.0-alpha: e42bd6d93a1d3433c486200587f8f9e12590a4d7
2828
refs/heads/tmp: 370fe2786109360f7c35b8ba552b83b773dd71d6
2929
refs/tags/1.0.0-alpha.2: 4c705f6bc559886632d3871b04f58aab093bfa2f

branches/beta/src/librustc_data_structures/transitive_relation.rs

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -267,8 +267,7 @@ impl<T:Debug+PartialEq> TransitiveRelation<T> {
267267
/// there exists an earlier element i<j such that i -> j. That is,
268268
/// after you run `pare_down`, you know that for all elements that
269269
/// remain in candidates, they cannot reach any of the elements that
270-
/// come after them. (Note that it may permute the ordering in some
271-
/// cases.)
270+
/// come after them.
272271
///
273272
/// Examples follow. Assume that a -> b -> c and x -> y -> z.
274273
///
@@ -278,24 +277,24 @@ impl<T:Debug+PartialEq> TransitiveRelation<T> {
278277
fn pare_down(candidates: &mut Vec<usize>, closure: &BitMatrix) {
279278
let mut i = 0;
280279
while i < candidates.len() {
281-
let candidate = candidates[i];
280+
let candidate_i = candidates[i];
282281
i += 1;
283282

284283
let mut j = i;
284+
let mut dead = 0;
285285
while j < candidates.len() {
286-
if closure.contains(candidate, candidates[j]) {
287-
// If `i` can reach `j`, then we can remove `j`. Given
288-
// how careful this algorithm is about ordering, it
289-
// may seem odd to use swap-remove. The reason it is
290-
// ok is that we are swapping two elements (`j` and
291-
// `max`) that are both to the right of our cursor
292-
// `i`, and the invariant that we are establishing
293-
// continues to hold for everything left of `i`.
294-
candidates.swap_remove(j);
286+
let candidate_j = candidates[j];
287+
if closure.contains(candidate_i, candidate_j) {
288+
// If `i` can reach `j`, then we can remove `j`. So just
289+
// mark it as dead and move on; subsequent indices will be
290+
// shifted into its place.
291+
dead += 1;
295292
} else {
296-
j += 1;
293+
candidates[j - dead] = candidate_j;
297294
}
295+
j += 1;
298296
}
297+
candidates.truncate(j - dead);
299298
}
300299
}
301300

0 commit comments

Comments
 (0)