Skip to content

Commit b39eb2a

Browse files
huonwluqmana
authored andcommitted
---
yaml --- r: 50175 b: refs/heads/auto c: 89a7407 h: refs/heads/master i: 50173: 178bc04 50171: fd30141 50167: 2b76acb 50159: c8d747e 50143: 35b75c1 50111: db24095 50047: 2213e19 49919: 7639267 49663: e5474e8 49151: ea2eafb v: v3
1 parent 110f498 commit b39eb2a

File tree

4 files changed

+44
-55
lines changed

4 files changed

+44
-55
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@ refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0
1414
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
1515
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1616
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
17-
refs/heads/auto: 794814945674d27a4fb68aedcea86c39dd5ccd4e
17+
refs/heads/auto: 89a7407c999449c56f9b00145cfbdfbb49fbde7c
1818
refs/heads/servo: af82457af293e2a842ba6b7759b70288da276167

branches/auto/src/libcore/container.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,9 @@ pub trait Map<K, V>: Mutable {
3838
/// Iterate over the map and mutate the contained values
3939
fn mutate_values(&mut self, f: &fn(&K, &mut V) -> bool);
4040

41-
/// Return a reference to the value corresponding to the key
41+
/// Return the value corresponding to the key in the map
4242
fn find(&self, key: &K) -> Option<&'self V>;
4343

44-
/// Return a mutable reference to the value corresponding to the key
45-
//fn find_mut(&mut self, key: &K) -> Option<&'self mut V>;
46-
4744
/// Insert a key-value pair into the map. An existing value for a
4845
/// key is replaced by the new value. Return true if the key did
4946
/// not already exist in the map.

branches/auto/src/librustc/middle/trans/tvec.rs

Lines changed: 39 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ use middle::ty;
2727
use util::common::indenter;
2828
use util::ppaux::ty_to_str;
2929

30+
use core::option::None;
3031
use core::uint;
3132
use core::vec;
3233
use syntax::ast;
@@ -413,30 +414,52 @@ pub fn write_content(bcx: block,
413414
return bcx;
414415
}
415416

416-
let tmpdatum = unpack_datum!(bcx, {
417+
let elem = unpack_datum!(bcx, {
417418
expr::trans_to_datum(bcx, element)
418419
});
419420

420-
let mut temp_cleanups = ~[];
421+
let next_bcx = sub_block(bcx, ~"expr_repeat: while next");
422+
let loop_bcx = loop_scope_block(bcx, next_bcx, None, ~"expr_repeat", None);
423+
let cond_bcx = scope_block(loop_bcx, None, ~"expr_repeat: loop cond");
424+
let set_bcx = scope_block(loop_bcx, None, ~"expr_repeat: body: set");
425+
let inc_bcx = scope_block(loop_bcx, None, ~"expr_repeat: body: inc");
426+
Br(bcx, loop_bcx.llbb);
421427

422-
for uint::range(0, count) |i| {
423-
let lleltptr = GEPi(bcx, lldest, [i]);
424-
if i < count - 1 {
425-
// Copy all but the last one in.
426-
bcx = tmpdatum.copy_to(bcx, INIT, lleltptr);
427-
} else {
428-
// Move the last one in.
429-
bcx = tmpdatum.move_to(bcx, INIT, lleltptr);
430-
}
431-
add_clean_temp_mem(bcx, lleltptr, vt.unit_ty);
432-
temp_cleanups.push(lleltptr);
428+
let loop_counter = {
429+
// i = 0
430+
let i = alloca(loop_bcx, bcx.ccx().int_type);
431+
Store(loop_bcx, C_uint(bcx.ccx(), 0), i);
432+
433+
Br(loop_bcx, cond_bcx.llbb);
434+
i
435+
};
436+
437+
{ // i < count
438+
let lhs = Load(cond_bcx, loop_counter);
439+
let rhs = C_uint(bcx.ccx(), count);
440+
let cond_val = ICmp(cond_bcx, lib::llvm::IntULT, lhs, rhs);
441+
442+
CondBr(cond_bcx, cond_val, set_bcx.llbb, next_bcx.llbb);
433443
}
434444

435-
for vec::each(temp_cleanups) |cleanup| {
436-
revoke_clean(bcx, *cleanup);
445+
{ // v[i] = elem
446+
let i = Load(set_bcx, loop_counter);
447+
let lleltptr = InBoundsGEP(set_bcx, lldest, [i]);
448+
let set_bcx = elem.copy_to(set_bcx, INIT, lleltptr);
449+
450+
Br(set_bcx, inc_bcx.llbb);
437451
}
438452

439-
return bcx;
453+
{ // i += 1
454+
let i = Load(inc_bcx, loop_counter);
455+
let plusone = Add(inc_bcx, i, C_uint(bcx.ccx(), 1));
456+
Store(inc_bcx, plusone, loop_counter);
457+
458+
Br(inc_bcx, cond_bcx.llbb);
459+
}
460+
461+
return next_bcx;
462+
440463
}
441464
}
442465
}

branches/auto/src/libstd/treemap.rs

Lines changed: 3 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ impl<K: TotalOrd, V> Map<K, V> for TreeMap<K, V> {
135135
mutate_values(&mut self.root, f);
136136
}
137137

138-
/// Return a reference to the value corresponding to the key
138+
/// Return the value corresponding to the key in the map
139139
fn find(&self, key: &K) -> Option<&'self V> {
140140
let mut current: &'self Option<~TreeNode<K, V>> = &self.root;
141141
loop {
@@ -189,12 +189,6 @@ pub impl<K: TotalOrd, V> TreeMap<K, V> {
189189
fn iter(&self) -> TreeMapIterator<'self, K, V> {
190190
TreeMapIterator{stack: ~[], node: &self.root}
191191
}
192-
193-
/// Return a mutable reference to the value corresponding to the key
194-
#[inline(always)]
195-
fn find_mut(&mut self, key: &K) -> Option<&'self mut V> {
196-
find_mut(&mut self.root, key)
197-
}
198192
}
199193

200194
/// Lazy forward iterator over a map
@@ -590,20 +584,8 @@ fn split<K: TotalOrd, V>(node: &mut ~TreeNode<K, V>) {
590584
}
591585
}
592586

593-
fn find_mut<K: TotalOrd, V>(node: &'r mut Option<~TreeNode<K, V>>, key: &K) -> Option<&'r mut V> {
594-
match *node {
595-
Some(ref mut x) => {
596-
match key.cmp(&x.key) {
597-
Less => find_mut(&mut x.left, key),
598-
Greater => find_mut(&mut x.right, key),
599-
Equal => Some(&mut x.value),
600-
}
601-
}
602-
None => None
603-
}
604-
}
605-
606-
fn insert<K: TotalOrd, V>(node: &mut Option<~TreeNode<K, V>>, key: K, value: V) -> bool {
587+
fn insert<K: TotalOrd, V>(node: &mut Option<~TreeNode<K, V>>, key: K,
588+
value: V) -> bool {
607589
match *node {
608590
Some(ref mut save) => {
609591
match key.cmp(&save.key) {
@@ -734,19 +716,6 @@ mod test_treemap {
734716
fail_unless!(m.find(&2) == None);
735717
}
736718

737-
#[test]
738-
fn test_find_mut() {
739-
let mut m = TreeMap::new();
740-
fail_unless!(m.insert(1, 12));
741-
fail_unless!(m.insert(2, 8));
742-
fail_unless!(m.insert(5, 14));
743-
let new = 100;
744-
match m.find_mut(&5) {
745-
None => fail!(), Some(x) => *x = new
746-
}
747-
assert_eq!(m.find(&5), Some(&new));
748-
}
749-
750719
#[test]
751720
fn insert_replace() {
752721
let mut m = TreeMap::new();

0 commit comments

Comments
 (0)