Skip to content

Commit a49846c

Browse files
committed
---
yaml --- r: 54109 b: refs/heads/dist-snap c: 585c572 h: refs/heads/master i: 54107: ab048d5 v: v3
1 parent 786f479 commit a49846c

File tree

9 files changed

+27
-159
lines changed

9 files changed

+27
-159
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c
99
refs/heads/incoming: 44d4d6de762f3f9aae1fedcf454c66b79b3ad58d
10-
refs/heads/dist-snap: e8bf0a4a49405cfde21910af889d626fbdd5bd52
10+
refs/heads/dist-snap: 585c57234f6f2dbab7d56ec1351e5aeb052d3edb
1111
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1212
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
1313
refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0

branches/dist-snap/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/dist-snap/src/libcore/hashmap.rs

Lines changed: 1 addition & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ pub mod linear {
2424
use rand;
2525
use uint;
2626
use vec;
27-
use util::unreachable;
2827

2928
static INITIAL_CAPACITY: uint = 32u; // 2^5
3029

@@ -193,14 +192,6 @@ pub mod linear {
193192
}
194193
}
195194
196-
#[inline(always)]
197-
fn mut_value_for_bucket(&mut self, idx: uint) -> &'self mut V {
198-
match self.buckets[idx] {
199-
Some(ref mut bkt) => &mut bkt.value,
200-
None => unreachable()
201-
}
202-
}
203-
204195
/// Inserts the key value pair into the buckets.
205196
/// Assumes that there will be a bucket.
206197
/// True if there was no previous entry with that key
@@ -347,25 +338,14 @@ pub mod linear {
347338
}
348339
}
349340
350-
/// Return a reference to the value corresponding to the key
341+
/// Return the value corresponding to the key in the map
351342
fn find(&self, k: &K) -> Option<&'self V> {
352343
match self.bucket_for_key(k) {
353344
FoundEntry(idx) => Some(self.value_for_bucket(idx)),
354345
TableFull | FoundHole(_) => None,
355346
}
356347
}
357348
358-
/// Return a mutable reference to the value corresponding to the key
359-
fn find_mut(&mut self, k: &K) -> Option<&'self mut V> {
360-
let idx = match self.bucket_for_key(k) {
361-
FoundEntry(idx) => idx,
362-
TableFull | FoundHole(_) => return None
363-
};
364-
unsafe { // FIXME(#4903)---requires flow-sensitive borrow checker
365-
Some(::cast::transmute_mut_region(self.mut_value_for_bucket(idx)))
366-
}
367-
}
368-
369349
/// Insert a key-value pair into the map. An existing value for a
370350
/// key is replaced by the new value. Return true if the key did
371351
/// not already exist in the map.
@@ -675,19 +655,6 @@ pub mod linear {
675655
fail_unless!(*m.get(&2) == 4);
676656
}
677657

678-
#[test]
679-
fn test_find_mut() {
680-
let mut m = LinearMap::new();
681-
fail_unless!(m.insert(1, 12));
682-
fail_unless!(m.insert(2, 8));
683-
fail_unless!(m.insert(5, 14));
684-
let new = 100;
685-
match m.find_mut(&5) {
686-
None => fail!(), Some(x) => *x = new
687-
}
688-
assert_eq!(m.find(&5), Some(&new));
689-
}
690-
691658
#[test]
692659
pub fn test_insert_overwrite() {
693660
let mut m = LinearMap::new();

branches/dist-snap/src/libcore/trie.rs

Lines changed: 2 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
//! An ordered map and set for integer keys implemented as a radix trie
11+
//! A radix trie for storing integers in sorted order
1212
1313
use prelude::*;
1414

@@ -90,7 +90,7 @@ impl<T> Map<uint, T> for TrieMap<T> {
9090
self.root.mutate_values(f);
9191
}
9292

93-
/// Return a reference to the value corresponding to the key
93+
/// Return the value corresponding to the key in the map
9494
#[inline(hint)]
9595
fn find(&self, key: &uint) -> Option<&'self T> {
9696
let mut node: &'self TrieNode<T> = &self.root;
@@ -111,12 +111,6 @@ impl<T> Map<uint, T> for TrieMap<T> {
111111
}
112112
}
113113

114-
/// Return a mutable reference to the value corresponding to the key
115-
#[inline(always)]
116-
fn find_mut(&mut self, key: &uint) -> Option<&'self mut T> {
117-
find_mut(&mut self.root.children[chunk(*key, 0)], *key, 1)
118-
}
119-
120114
/// Insert a key-value pair into the map. An existing value for a
121115
/// key is replaced by the new value. Return true if the key did
122116
/// not already exist in the map.
@@ -282,17 +276,6 @@ fn chunk(n: uint, idx: uint) -> uint {
282276
(n >> sh) & MASK
283277
}
284278

285-
fn find_mut<T>(child: &'r mut Child<T>, key: uint, idx: uint) -> Option<&'r mut T> {
286-
unsafe { // FIXME(#4903)---requires flow-sensitive borrow checker
287-
(match *child {
288-
External(_, ref value) => Some(cast::transmute_mut(value)),
289-
Internal(ref x) => find_mut(cast::transmute_mut(&x.children[chunk(key, idx)]),
290-
key, idx + 1),
291-
Nothing => None
292-
}).map_consume(|x| cast::transmute_mut_region(x))
293-
}
294-
}
295-
296279
fn insert<T>(count: &mut uint, child: &mut Child<T>, key: uint, value: T,
297280
idx: uint) -> bool {
298281
let mut tmp = Nothing;
@@ -374,22 +357,8 @@ pub fn check_integrity<T>(trie: &TrieNode<T>) {
374357
#[cfg(test)]
375358
mod tests {
376359
use super::*;
377-
use core::option::{Some, None};
378360
use uint;
379361

380-
#[test]
381-
fn test_find_mut() {
382-
let mut m = TrieMap::new();
383-
fail_unless!(m.insert(1, 12));
384-
fail_unless!(m.insert(2, 8));
385-
fail_unless!(m.insert(5, 14));
386-
let new = 100;
387-
match m.find_mut(&5) {
388-
None => fail!(), Some(x) => *x = new
389-
}
390-
assert_eq!(m.find(&5), Some(&new));
391-
}
392-
393362
#[test]
394363
fn test_step() {
395364
let mut trie = TrieMap::new();

branches/dist-snap/src/librustdoc/tystr_pass.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,13 @@ fn get_fn_sig(srv: astsrv::Srv, fn_id: doc::AstId) -> Option<~str> {
6969
match ctxt.ast_map.get(&fn_id) {
7070
ast_map::node_item(@ast::item {
7171
ident: ident,
72-
node: ast::item_fn(ref decl, _, ref tys, _), _
72+
node: ast::item_fn(ref decl, purity, ref tys, _), _
7373
}, _) |
7474
ast_map::node_foreign_item(@ast::foreign_item {
7575
ident: ident,
76-
node: ast::foreign_item_fn(ref decl, _, ref tys), _
76+
node: ast::foreign_item_fn(ref decl, purity, ref tys), _
7777
}, _, _, _) => {
78-
Some(pprust::fun_to_str(decl, ident, None, tys,
78+
Some(pprust::fun_to_str(decl, purity, ident, None, tys,
7979
extract::interner()))
8080
}
8181
_ => fail!(~"get_fn_sig: fn_id not bound to a fn item")
@@ -214,6 +214,7 @@ fn get_method_sig(
214214
ast::required(ty_m) => {
215215
Some(pprust::fun_to_str(
216216
&ty_m.decl,
217+
ty_m.purity,
217218
ty_m.ident,
218219
Some(ty_m.self_ty.node),
219220
&ty_m.generics,
@@ -223,6 +224,7 @@ fn get_method_sig(
223224
ast::provided(m) => {
224225
Some(pprust::fun_to_str(
225226
&m.decl,
227+
m.purity,
226228
m.ident,
227229
Some(m.self_ty.node),
228230
&m.generics,
@@ -243,6 +245,7 @@ fn get_method_sig(
243245
Some(method) => {
244246
Some(pprust::fun_to_str(
245247
&method.decl,
248+
method.purity,
246249
method.ident,
247250
Some(method.self_ty.node),
248251
&method.generics,

branches/dist-snap/src/libstd/smallintmap.rs

Lines changed: 2 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ impl<V> Map<uint, V> for SmallIntMap<V> {
8686
self.each(|&(_, v)| blk(v))
8787
}
8888

89-
/// Iterate over the map and mutate the contained values
89+
/// Visit all key-value pairs in order
9090
fn mutate_values(&mut self, it: &fn(&uint, &'self mut V) -> bool) {
9191
for uint::range(0, self.v.len()) |i| {
9292
match self.v[i] {
@@ -96,7 +96,7 @@ impl<V> Map<uint, V> for SmallIntMap<V> {
9696
}
9797
}
9898

99-
/// Return a reference to the value corresponding to the key
99+
/// Iterate over the map and mutate the contained values
100100
fn find(&self, key: &uint) -> Option<&'self V> {
101101
if *key < self.v.len() {
102102
match self.v[*key] {
@@ -108,18 +108,6 @@ impl<V> Map<uint, V> for SmallIntMap<V> {
108108
}
109109
}
110110

111-
/// Return a mutable reference to the value corresponding to the key
112-
fn find_mut(&mut self, key: &uint) -> Option<&'self mut V> {
113-
if *key < self.v.len() {
114-
match self.v[*key] {
115-
Some(ref mut value) => Some(value),
116-
None => None
117-
}
118-
} else {
119-
None
120-
}
121-
}
122-
123111
/// Insert a key-value pair into the map. An existing value for a
124112
/// key is replaced by the new value. Return true if the key did
125113
/// not already exist in the map.
@@ -172,20 +160,6 @@ pub impl<V:Copy> SmallIntMap<V> {
172160
#[cfg(test)]
173161
mod tests {
174162
use super::SmallIntMap;
175-
use core::prelude::*;
176-
177-
#[test]
178-
fn test_find_mut() {
179-
let mut m = SmallIntMap::new();
180-
fail_unless!(m.insert(1, 12));
181-
fail_unless!(m.insert(2, 8));
182-
fail_unless!(m.insert(5, 14));
183-
let new = 100;
184-
match m.find_mut(&5) {
185-
None => fail!(), Some(x) => *x = new
186-
}
187-
assert_eq!(m.find(&5), Some(&new));
188-
}
189163

190164
#[test]
191165
fn test_len() {

branches/dist-snap/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 {
@@ -152,12 +152,6 @@ impl<K: TotalOrd, V> Map<K, V> for TreeMap<K, V> {
152152
}
153153
}
154154

155-
/// Return a mutable reference to the value corresponding to the key
156-
#[inline(always)]
157-
fn find_mut(&mut self, key: &K) -> Option<&'self mut V> {
158-
find_mut(&mut self.root, key)
159-
}
160-
161155
/// Insert a key-value pair into the map. An existing value for a
162156
/// key is replaced by the new value. Return true if the key did
163157
/// not already exist in the 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)