Skip to content

Commit 50363dc

Browse files
committed
---
yaml --- r: 49962 b: refs/heads/auto c: d856215 h: refs/heads/master v: v3
1 parent 1706265 commit 50363dc

File tree

5 files changed

+42
-34
lines changed

5 files changed

+42
-34
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: 5a77a1048897a12c9031d3e0b3867f0c6e3673ea
17+
refs/heads/auto: d856215b925441a4889cb23cab5758c36e4a4746
1818
refs/heads/servo: af82457af293e2a842ba6b7759b70288da276167

branches/auto/src/libcore/rt/thread_local_storage.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ type pthread_key_t = c_ulong;
4040

4141
#[cfg(target_os="linux")]
4242
#[cfg(target_os="freebsd")]
43-
#[cfg(target_os="android")]
4443
#[allow(non_camel_case_types)] // foreign type
4544
type pthread_key_t = c_uint;
4645

branches/auto/src/libcore/trie.rs

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ impl<T> Map<uint, T> for TrieMap<T> {
137137
}
138138

139139
impl<T> TrieMap<T> {
140+
/// Create an empty TrieMap
140141
#[inline(always)]
141142
static pure fn new() -> TrieMap<T> {
142143
TrieMap{root: TrieNode::new(), length: 0}
@@ -191,6 +192,12 @@ impl Mutable for TrieSet {
191192
}
192193

193194
impl TrieSet {
195+
/// Create an empty TrieSet
196+
#[inline(always)]
197+
static pure fn new() -> TrieSet {
198+
TrieSet{map: TrieMap::new()}
199+
}
200+
194201
/// Return true if the set contains a value
195202
#[inline(always)]
196203
pure fn contains(&self, value: &uint) -> bool {
@@ -265,8 +272,8 @@ impl<T> TrieNode<T> {
265272
// if this was done via a trait, the key could be generic
266273
#[inline(always)]
267274
pure fn chunk(n: uint, idx: uint) -> uint {
268-
let real_idx = uint::bytes - 1 - idx;
269-
(n >> (SHIFT * real_idx)) & MASK
275+
let sh = uint::bits - (SHIFT * (idx + 1));
276+
(n >> sh) & MASK
270277
}
271278

272279
fn insert<T>(count: &mut uint, child: &mut Child<T>, key: uint, value: T,
@@ -462,4 +469,26 @@ mod tests {
462469
n -= 1;
463470
}
464471
}
472+
473+
#[test]
474+
fn test_sane_chunk() {
475+
let x = 1;
476+
let y = 1 << (uint::bits - 1);
477+
478+
let mut trie = TrieSet::new();
479+
480+
fail_unless!(trie.insert(x));
481+
fail_unless!(trie.insert(y));
482+
483+
fail_unless!(trie.len() == 2);
484+
485+
let expected = [x, y];
486+
487+
let mut i = 0;
488+
489+
for trie.each |x| {
490+
fail_unless!(expected[i] == *x);
491+
i += 1;
492+
}
493+
}
465494
}

branches/auto/src/libstd/deque.rs

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -22,61 +22,40 @@ pub struct Deque<T> {
2222
}
2323

2424
impl<T> Container for Deque<T> {
25-
/// Return the number of elements in the deque
2625
pure fn len(&self) -> uint { self.nelts }
27-
28-
/// Return true if the deque contains no elements
2926
pure fn is_empty(&self) -> bool { self.len() == 0 }
3027
}
3128

3229
impl<T> Mutable for Deque<T> {
33-
/// Clear the deque, removing all values.
3430
fn clear(&mut self) {
35-
for self.elts.each_mut |x| { *x = None }
31+
for vec::each_mut(self.elts) |x| { *x = None }
3632
self.nelts = 0;
3733
self.lo = 0;
3834
self.hi = 0;
3935
}
4036
}
4137

4238
pub impl<T> Deque<T> {
43-
/// Create an empty Deque
4439
static pure fn new() -> Deque<T> {
4540
Deque{nelts: 0, lo: 0, hi: 0,
4641
elts: vec::from_fn(initial_capacity, |_| None)}
4742
}
4843

49-
/// Return a reference to the first element in the deque
50-
///
51-
/// Fails if the deque is empty
5244
fn peek_front(&self) -> &self/T { get(self.elts, self.lo) }
53-
54-
/// Return a reference to the last element in the deque
55-
///
56-
/// Fails if the deque is empty
5745
fn peek_back(&self) -> &self/T { get(self.elts, self.hi - 1u) }
5846

59-
/// Retrieve an element in the deque by index
60-
///
61-
/// Fails if there is no element with the given index
6247
fn get(&self, i: int) -> &self/T {
6348
let idx = (self.lo + (i as uint)) % self.elts.len();
6449
get(self.elts, idx)
6550
}
6651

67-
/// Remove and return the first element in the deque
68-
///
69-
/// Fails if the deque is empty
7052
fn pop_front(&mut self) -> T {
7153
let mut result = self.elts[self.lo].swap_unwrap();
7254
self.lo = (self.lo + 1u) % self.elts.len();
7355
self.nelts -= 1u;
7456
result
7557
}
7658

77-
/// Remove and return the last element in the deque
78-
///
79-
/// Fails if the deque is empty
8059
fn pop_back(&mut self) -> T {
8160
if self.hi == 0u {
8261
self.hi = self.elts.len() - 1u;
@@ -87,7 +66,6 @@ pub impl<T> Deque<T> {
8766
result
8867
}
8968

90-
/// Prepend an element to the deque
9169
fn add_front(&mut self, t: T) {
9270
let oldlo = self.lo;
9371
if self.lo == 0u {
@@ -102,7 +80,6 @@ pub impl<T> Deque<T> {
10280
self.nelts += 1u;
10381
}
10482

105-
/// Append an element to the deque
10683
fn add_back(&mut self, t: T) {
10784
if self.lo == self.hi && self.nelts != 0u {
10885
self.elts = grow(self.nelts, self.lo, self.elts);

branches/auto/src/libstd/treemap.rs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -636,13 +636,14 @@ fn remove<K: TotalOrd, V>(node: &mut Option<~TreeNode<K, V>>,
636636
fn heir_swap<K: TotalOrd, V>(node: &mut ~TreeNode<K, V>,
637637
child: &mut Option<~TreeNode<K, V>>) {
638638
// *could* be done without recursion, but it won't borrow check
639-
for child.each_mut |x| {
640-
if x.right.is_some() {
641-
heir_swap(node, &mut x.right);
639+
do child.mutate |mut child| {
640+
if child.right.is_some() {
641+
heir_swap(node, &mut child.right);
642642
} else {
643-
node.key <-> x.key;
644-
node.value <-> x.value;
643+
node.key <-> child.key;
644+
node.value <-> child.value;
645645
}
646+
child
646647
}
647648
}
648649

@@ -688,7 +689,7 @@ fn remove<K: TotalOrd, V>(node: &mut Option<~TreeNode<K, V>>,
688689
save.level -= 1;
689690

690691
if right_level > save.level {
691-
for save.right.each_mut |x| { x.level = save.level }
692+
do save.right.mutate |mut x| { x.level = save.level; x }
692693
}
693694

694695
skew(save);
@@ -987,6 +988,8 @@ mod test_treemap {
987988
let m = m;
988989
let mut a = m.iter();
989990

991+
// FIXME: #4492 (ICE): iter.get() == Some((&x1, &y1))
992+
990993
fail_unless!(map_next(&mut a).unwrap() == (&x1, &y1));
991994
fail_unless!(map_next(&mut a).unwrap() == (&x2, &y2));
992995
fail_unless!(map_next(&mut a).unwrap() == (&x3, &y3));

0 commit comments

Comments
 (0)