Skip to content

Commit 6aa5c0d

Browse files
committed
---
yaml --- r: 139213 b: refs/heads/try2 c: 705c796 h: refs/heads/master i: 139211: 803fe2d v: v3
1 parent 9939664 commit 6aa5c0d

File tree

3 files changed

+102
-118
lines changed

3 files changed

+102
-118
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: 0c8c3b42326c17d59204106d120508969e2b338c
8+
refs/heads/try2: 705c796ffa78417592b9e36d975cd432a4dc8417
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/libstd/priority_queue.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ pub impl <T:Ord> PriorityQueue<T> {
112112
while end > 1 {
113113
end -= 1;
114114
q.data[end] <-> q.data[0];
115-
unsafe { q.siftdown_range(0, end) } // purity-checking workaround
115+
q.siftdown_range(0, end)
116116
}
117117
q.to_vec()
118118
}
@@ -126,7 +126,7 @@ pub impl <T:Ord> PriorityQueue<T> {
126126
let mut n = q.len() / 2;
127127
while n > 0 {
128128
n -= 1;
129-
unsafe { q.siftdown(n) }; // purity-checking workaround
129+
q.siftdown(n)
130130
}
131131
q
132132
}

branches/try2/src/libstd/treemap.rs

Lines changed: 99 additions & 115 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,9 @@ impl<K: Eq + TotalOrd, V: Eq> Eq for TreeMap<K, V> {
4343
let mut x = self.iter();
4444
let mut y = other.iter();
4545
for self.len().times {
46-
unsafe { // unsafe as a purity workaround
47-
if map_next(&mut x).unwrap() !=
48-
map_next(&mut y).unwrap() {
49-
return false
50-
}
46+
if map_next(&mut x).unwrap() !=
47+
map_next(&mut y).unwrap() {
48+
return false
5149
}
5250
}
5351
true
@@ -64,12 +62,10 @@ fn lt<K: Ord + TotalOrd, V>(a: &TreeMap<K, V>,
6462

6563
let (a_len, b_len) = (a.len(), b.len());
6664
for uint::min(a_len, b_len).times {
67-
unsafe { // purity workaround
68-
let (key_a,_) = map_next(&mut x).unwrap();
69-
let (key_b,_) = map_next(&mut y).unwrap();
70-
if *key_a < *key_b { return true; }
71-
if *key_a > *key_b { return false; }
72-
}
65+
let (key_a,_) = map_next(&mut x).unwrap();
66+
let (key_b,_) = map_next(&mut y).unwrap();
67+
if *key_a < *key_b { return true; }
68+
if *key_a > *key_b { return false; }
7369
};
7470

7571
a_len < b_len
@@ -311,17 +307,15 @@ impl<T: TotalOrd> Set<T> for TreeSet<T> {
311307
fn is_disjoint(&self, other: &TreeSet<T>) -> bool {
312308
let mut x = self.iter();
313309
let mut y = other.iter();
314-
unsafe { // purity workaround
315-
let mut a = set_next(&mut x);
316-
let mut b = set_next(&mut y);
317-
while a.is_some() && b.is_some() {
318-
let a1 = a.unwrap();
319-
let b1 = b.unwrap();
320-
match a1.cmp(b1) {
321-
Less => a = set_next(&mut x),
322-
Greater => b = set_next(&mut y),
323-
Equal => return false
324-
}
310+
let mut a = set_next(&mut x);
311+
let mut b = set_next(&mut y);
312+
while a.is_some() && b.is_some() {
313+
let a1 = a.unwrap();
314+
let b1 = b.unwrap();
315+
match a1.cmp(b1) {
316+
Less => a = set_next(&mut x),
317+
Greater => b = set_next(&mut y),
318+
Equal => return false
325319
}
326320
}
327321
true
@@ -337,25 +331,23 @@ impl<T: TotalOrd> Set<T> for TreeSet<T> {
337331
fn is_superset(&self, other: &TreeSet<T>) -> bool {
338332
let mut x = self.iter();
339333
let mut y = other.iter();
340-
unsafe { // purity workaround
341-
let mut a = set_next(&mut x);
342-
let mut b = set_next(&mut y);
343-
while b.is_some() {
344-
if a.is_none() {
345-
return false
346-
}
347-
348-
let a1 = a.unwrap();
349-
let b1 = b.unwrap();
334+
let mut a = set_next(&mut x);
335+
let mut b = set_next(&mut y);
336+
while b.is_some() {
337+
if a.is_none() {
338+
return false
339+
}
350340

351-
match a1.cmp(b1) {
352-
Less => (),
353-
Greater => return false,
354-
Equal => b = set_next(&mut y),
355-
}
341+
let a1 = a.unwrap();
342+
let b1 = b.unwrap();
356343

357-
a = set_next(&mut x);
344+
match a1.cmp(b1) {
345+
Less => (),
346+
Greater => return false,
347+
Equal => b = set_next(&mut y),
358348
}
349+
350+
a = set_next(&mut x);
359351
}
360352
true
361353
}
@@ -365,29 +357,27 @@ impl<T: TotalOrd> Set<T> for TreeSet<T> {
365357
let mut x = self.iter();
366358
let mut y = other.iter();
367359

368-
unsafe { // purity workaround
369-
let mut a = set_next(&mut x);
370-
let mut b = set_next(&mut y);
360+
let mut a = set_next(&mut x);
361+
let mut b = set_next(&mut y);
371362

372-
while a.is_some() {
373-
if b.is_none() {
374-
return do a.while_some() |a1| {
375-
if f(a1) { set_next(&mut x) } else { None }
376-
}
363+
while a.is_some() {
364+
if b.is_none() {
365+
return do a.while_some() |a1| {
366+
if f(a1) { set_next(&mut x) } else { None }
377367
}
368+
}
378369

379-
let a1 = a.unwrap();
380-
let b1 = b.unwrap();
370+
let a1 = a.unwrap();
371+
let b1 = b.unwrap();
381372

382-
let cmp = a1.cmp(b1);
373+
let cmp = a1.cmp(b1);
383374

384-
if cmp == Less {
385-
if !f(a1) { return }
386-
a = set_next(&mut x);
387-
} else {
388-
if cmp == Equal { a = set_next(&mut x) }
389-
b = set_next(&mut y);
390-
}
375+
if cmp == Less {
376+
if !f(a1) { return }
377+
a = set_next(&mut x);
378+
} else {
379+
if cmp == Equal { a = set_next(&mut x) }
380+
b = set_next(&mut y);
391381
}
392382
}
393383
}
@@ -398,37 +388,35 @@ impl<T: TotalOrd> Set<T> for TreeSet<T> {
398388
let mut x = self.iter();
399389
let mut y = other.iter();
400390

401-
unsafe { // purity workaround
402-
let mut a = set_next(&mut x);
403-
let mut b = set_next(&mut y);
391+
let mut a = set_next(&mut x);
392+
let mut b = set_next(&mut y);
404393

405-
while a.is_some() {
406-
if b.is_none() {
407-
return do a.while_some() |a1| {
408-
if f(a1) { set_next(&mut x) } else { None }
409-
}
394+
while a.is_some() {
395+
if b.is_none() {
396+
return do a.while_some() |a1| {
397+
if f(a1) { set_next(&mut x) } else { None }
410398
}
399+
}
411400

412-
let a1 = a.unwrap();
413-
let b1 = b.unwrap();
401+
let a1 = a.unwrap();
402+
let b1 = b.unwrap();
414403

415-
let cmp = a1.cmp(b1);
404+
let cmp = a1.cmp(b1);
416405

417-
if cmp == Less {
418-
if !f(a1) { return }
419-
a = set_next(&mut x);
406+
if cmp == Less {
407+
if !f(a1) { return }
408+
a = set_next(&mut x);
409+
} else {
410+
if cmp == Greater {
411+
if !f(b1) { return }
420412
} else {
421-
if cmp == Greater {
422-
if !f(b1) { return }
423-
} else {
424-
a = set_next(&mut x);
425-
}
426-
b = set_next(&mut y);
413+
a = set_next(&mut x);
427414
}
415+
b = set_next(&mut y);
428416
}
429-
do b.while_some |b1| {
430-
if f(b1) { set_next(&mut y) } else { None }
431-
}
417+
}
418+
do b.while_some |b1| {
419+
if f(b1) { set_next(&mut y) } else { None }
432420
}
433421
}
434422

@@ -437,24 +425,22 @@ impl<T: TotalOrd> Set<T> for TreeSet<T> {
437425
let mut x = self.iter();
438426
let mut y = other.iter();
439427

440-
unsafe { // purity workaround
441-
let mut a = set_next(&mut x);
442-
let mut b = set_next(&mut y);
428+
let mut a = set_next(&mut x);
429+
let mut b = set_next(&mut y);
443430

444-
while a.is_some() && b.is_some() {
445-
let a1 = a.unwrap();
446-
let b1 = b.unwrap();
431+
while a.is_some() && b.is_some() {
432+
let a1 = a.unwrap();
433+
let b1 = b.unwrap();
447434

448-
let cmp = a1.cmp(b1);
435+
let cmp = a1.cmp(b1);
449436

450-
if cmp == Less {
451-
a = set_next(&mut x);
452-
} else {
453-
if cmp == Equal {
454-
if !f(a1) { return }
455-
}
456-
b = set_next(&mut y);
437+
if cmp == Less {
438+
a = set_next(&mut x);
439+
} else {
440+
if cmp == Equal {
441+
if !f(a1) { return }
457442
}
443+
b = set_next(&mut y);
458444
}
459445
}
460446
}
@@ -464,36 +450,34 @@ impl<T: TotalOrd> Set<T> for TreeSet<T> {
464450
let mut x = self.iter();
465451
let mut y = other.iter();
466452

467-
unsafe { // purity workaround
468-
let mut a = set_next(&mut x);
469-
let mut b = set_next(&mut y);
453+
let mut a = set_next(&mut x);
454+
let mut b = set_next(&mut y);
470455

471-
while a.is_some() {
472-
if b.is_none() {
473-
return do a.while_some() |a1| {
474-
if f(a1) { set_next(&mut x) } else { None }
475-
}
456+
while a.is_some() {
457+
if b.is_none() {
458+
return do a.while_some() |a1| {
459+
if f(a1) { set_next(&mut x) } else { None }
476460
}
461+
}
477462

478-
let a1 = a.unwrap();
479-
let b1 = b.unwrap();
463+
let a1 = a.unwrap();
464+
let b1 = b.unwrap();
480465

481-
let cmp = a1.cmp(b1);
466+
let cmp = a1.cmp(b1);
482467

483-
if cmp == Greater {
484-
if !f(b1) { return }
468+
if cmp == Greater {
469+
if !f(b1) { return }
470+
b = set_next(&mut y);
471+
} else {
472+
if !f(a1) { return }
473+
if cmp == Equal {
485474
b = set_next(&mut y);
486-
} else {
487-
if !f(a1) { return }
488-
if cmp == Equal {
489-
b = set_next(&mut y);
490-
}
491-
a = set_next(&mut x);
492475
}
476+
a = set_next(&mut x);
493477
}
494-
do b.while_some |b1| {
495-
if f(b1) { set_next(&mut y) } else { None }
496-
}
478+
}
479+
do b.while_some |b1| {
480+
if f(b1) { set_next(&mut y) } else { None }
497481
}
498482
}
499483
}

0 commit comments

Comments
 (0)