Skip to content

Commit 162176d

Browse files
committed
---
yaml --- r: 51351 b: refs/heads/incoming c: 9c40ebb h: refs/heads/master i: 51349: bf41837 51347: a73f7b7 51343: dfcb1cc v: v3
1 parent ae6a4cd commit 162176d

File tree

10 files changed

+92
-68
lines changed

10 files changed

+92
-68
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ refs/heads/try: 8eb2bab100b42f0ba751552d8eff00eb2134c55a
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c
9-
refs/heads/incoming: becad9bb07423ed4d0d8b192cce83de99b535e86
9+
refs/heads/incoming: 9c40ebbb9a70b14a87d09bcd873c9c788627b3dc
1010
refs/heads/dist-snap: 8b98e5a296d95c5e832db0756828e5bec31c6f50
1111
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1212
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/incoming/src/libcore/container.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,6 @@ pub trait Map<K, V>: Mutable {
3535
/// Visit all values
3636
pure fn each_value(&self, f: &fn(&V) -> bool);
3737

38-
/// Iterate over the map and mutate the contained values
39-
fn mutate_values(&mut self, f: &fn(&K, &mut V) -> bool);
40-
4138
/// Return the value corresponding to the key in the map
4239
pure fn find(&self, key: &K) -> Option<&self/V>;
4340

branches/incoming/src/libcore/hashmap.rs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -324,19 +324,6 @@ pub mod linear {
324324
self.each(|&(_, v)| blk(v))
325325
}
326326
327-
/// Iterate over the map and mutate the contained values
328-
fn mutate_values(&mut self, blk: &fn(&'self K,
329-
&'self mut V) -> bool) {
330-
for uint::range(0, self.buckets.len()) |i| {
331-
match self.buckets[i] {
332-
Some(Bucket{key: ref key, value: ref mut value, _}) => {
333-
if !blk(key, value) { return }
334-
}
335-
None => ()
336-
}
337-
}
338-
}
339-
340327
/// Return the value corresponding to the key in the map
341328
pure fn find(&self, k: &K) -> Option<&self/V> {
342329
match self.bucket_for_key(k) {

branches/incoming/src/libcore/trie.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -81,16 +81,11 @@ impl<T> Map<uint, T> for TrieMap<T> {
8181

8282
/// Visit all values in order
8383
#[inline(always)]
84-
pure fn each_value(&self, f: &fn(&T) -> bool) {
84+
pure fn each_value(&self,
85+
f: &fn(&T) -> bool) {
8586
self.each(|&(_, v)| f(v))
8687
}
8788

88-
/// Iterate over the map and mutate the contained values
89-
#[inline(always)]
90-
fn mutate_values(&mut self, f: &fn(&uint, &mut T) -> bool) {
91-
self.root.mutate_values(f);
92-
}
93-
9489
/// Return the value corresponding to the key in the map
9590
#[inline(hint)]
9691
pure fn find(&self, key: &uint) -> Option<&self/T> {
@@ -155,6 +150,11 @@ impl<T> TrieMap<T> {
155150
pure fn each_value_reverse(&self, f: &fn(&T) -> bool) {
156151
self.each_reverse(|&(_, v)| f(v))
157152
}
153+
154+
/// Iterate over the map and mutate the contained values
155+
fn mutate_values(&mut self, f: &fn(uint, &mut T) -> bool) {
156+
self.root.mutate_values(f);
157+
}
158158
}
159159

160160
pub struct TrieSet {
@@ -248,13 +248,13 @@ impl<T> TrieNode<T> {
248248
true
249249
}
250250

251-
fn mutate_values(&mut self, f: &fn(&uint, &mut T) -> bool) -> bool {
251+
fn mutate_values(&mut self, f: &fn(uint, &mut T) -> bool) -> bool {
252252
for vec::each_mut(self.children) |child| {
253253
match *child {
254254
Internal(ref mut x) => if !x.mutate_values(f) {
255255
return false
256256
},
257-
External(k, ref mut v) => if !f(&k, v) { return false },
257+
External(k, ref mut v) => if !f(k, v) { return false },
258258
Nothing => ()
259259
}
260260
}
@@ -269,8 +269,8 @@ pure fn chunk(n: uint, idx: uint) -> uint {
269269
(n >> (SHIFT * real_idx)) & MASK
270270
}
271271

272-
fn insert<T>(count: &mut uint, child: &mut Child<T>, key: uint, value: T,
273-
idx: uint) -> bool {
272+
fn insert<T>(count: &mut uint, child: &mut Child<T>, key: uint,
273+
value: T, idx: uint) -> bool {
274274
let mut tmp = Nothing;
275275
tmp <-> *child;
276276
let mut added = false;

branches/incoming/src/librust/rust.rc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
// except according to those terms.
1010

1111
// rust - central access to other rust tools
12-
// XXX: Make commands run and test emit proper file endings on winds
13-
// XXX: Make run only accept source that emits an executable
12+
// FIXME #2238 Make commands run and test emit proper file endings on winds
13+
// FIXME #2238 Make run only accept source that emits an executable
1414

1515
#[deny(deprecated_self)];
1616

branches/incoming/src/librustc/middle/trans/base.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -867,7 +867,7 @@ pub fn in_lpad_scope_cx(bcx: block, f: &fn(+si: &mut scope_info)) {
867867
let mut bcx = bcx;
868868
loop {
869869
{
870-
// XXX: Borrow check bug workaround.
870+
// FIXME #4280: Borrow check bug workaround.
871871
let kind: &mut block_kind = &mut *bcx.kind;
872872
match *kind {
873873
block_scope(ref mut inf) => {
@@ -1272,7 +1272,7 @@ pub fn cleanup_and_leave(bcx: block,
12721272
}
12731273

12741274
{
1275-
// XXX: Borrow check bug workaround.
1275+
// FIXME #4280: Borrow check bug workaround.
12761276
let kind: &mut block_kind = &mut *cur.kind;
12771277
match *kind {
12781278
block_scope(ref mut inf) if !inf.cleanups.is_empty() => {
@@ -1850,8 +1850,7 @@ pub fn trans_enum_variant(ccx: @CrateContext,
18501850
};
18511851
let fcx = new_fn_ctxt_w_id(ccx, ~[], llfndecl, variant.node.id, None,
18521852
param_substs, None);
1853-
// XXX: Bad copy.
1854-
let raw_llargs = create_llargs_for_fn_args(fcx, no_self, copy fn_args);
1853+
let raw_llargs = create_llargs_for_fn_args(fcx, no_self, fn_args);
18551854
let ty_param_substs = match param_substs {
18561855
Some(ref substs) => /*bad*/copy substs.tys,
18571856
None => ~[]

branches/incoming/src/libstd/smallintmap.rs

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -85,17 +85,7 @@ impl<V> Map<uint, V> for SmallIntMap<V> {
8585
self.each(|&(_, v)| blk(v))
8686
}
8787

88-
/// Visit all key-value pairs in order
89-
fn mutate_values(&mut self, it: &fn(&uint, &'self mut V) -> bool) {
90-
for uint::range(0, self.v.len()) |i| {
91-
match self.v[i] {
92-
Some(ref mut elt) => if !it(&i, elt) { break },
93-
None => ()
94-
}
95-
}
96-
}
97-
98-
/// Iterate over the map and mutate the contained values
88+
/// Return the value corresponding to the key in the map
9989
pure fn find(&self, key: &uint) -> Option<&self/V> {
10090
if *key < self.v.len() {
10191
match self.v[*key] {

branches/incoming/src/libstd/treemap.rs

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -134,11 +134,6 @@ impl<K: TotalOrd, V> Map<K, V> for TreeMap<K, V> {
134134
self.each(|&(_, v)| f(v))
135135
}
136136

137-
/// Iterate over the map and mutate the contained values
138-
fn mutate_values(&mut self, f: &fn(&'self K, &'self mut V) -> bool) {
139-
mutate_values(&mut self.root, f);
140-
}
141-
142137
/// Return the value corresponding to the key in the map
143138
pure fn find(&self, key: &K) -> Option<&self/V> {
144139
let mut current: &self/Option<~TreeNode<K, V>> = &self.root;
@@ -563,20 +558,6 @@ pure fn each_reverse<K: TotalOrd, V>(node: &r/Option<~TreeNode<K, V>>,
563558
}
564559
}
565560

566-
fn mutate_values<K: TotalOrd, V>(node: &'r mut Option<~TreeNode<K, V>>,
567-
f: &fn(&'r K, &'r mut V) -> bool) -> bool {
568-
match *node {
569-
Some(~TreeNode{key: ref key, value: ref mut value, left: ref mut left,
570-
right: ref mut right, _}) => {
571-
if !mutate_values(left, f) { return false }
572-
if !f(key, value) { return false }
573-
if !mutate_values(right, f) { return false }
574-
}
575-
None => return false
576-
}
577-
true
578-
}
579-
580561
// Remove left horizontal link by rotating right
581562
fn skew<K: TotalOrd, V>(node: &mut ~TreeNode<K, V>) {
582563
if node.left.map_default(false, |x| x.level == node.level) {
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// Based on threadring.erlang by Jira Isa
12+
13+
fn start(n_tasks: int, token: int) {
14+
let mut (p, ch1) = comm::stream();
15+
ch1.send(token);
16+
// XXX could not get this to work with a range closure
17+
let mut i = 2;
18+
while i <= n_tasks {
19+
let (next_p, ch) = comm::stream();
20+
let imm_i = i;
21+
let imm_p = p;
22+
do task::spawn {
23+
roundtrip(imm_i, n_tasks, &imm_p, &ch);
24+
};
25+
p = next_p;
26+
i += 1;
27+
}
28+
let imm_p = p;
29+
let imm_ch = ch1;
30+
do task::spawn {
31+
roundtrip(1, n_tasks, &imm_p, &imm_ch);
32+
}
33+
}
34+
35+
fn roundtrip(id: int, n_tasks: int, p: &comm::Port<int>, ch: &comm::Chan<int>) {
36+
while (true) {
37+
match p.recv() {
38+
1 => {
39+
io::println(fmt!("%d\n", id));
40+
return;
41+
}
42+
token => {
43+
debug!("thread: %d got token: %d", id, token);
44+
ch.send(token - 1);
45+
if token <= n_tasks {
46+
return;
47+
}
48+
}
49+
}
50+
}
51+
}
52+
53+
fn main() {
54+
let args = if os::getenv(~"RUST_BENCH").is_some() {
55+
~[~"", ~"2000000", ~"503"]
56+
}
57+
else {
58+
os::args()
59+
};
60+
let token = if args.len() > 1u {
61+
int::from_str(args[1]).get()
62+
}
63+
else {
64+
1000
65+
};
66+
let n_tasks = if args.len() > 2u {
67+
int::from_str(args[2]).get()
68+
}
69+
else {
70+
503
71+
};
72+
start(n_tasks, token);
73+
74+
}

branches/incoming/src/test/run-pass/class-impl-very-parameterized-trait.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,6 @@ impl<T> Map<int, T> for cat<T> {
8181
for self.each |&(_, v)| { if !f(v) { break; } loop;};
8282
}
8383

84-
fn mutate_values(&mut self, f: &fn(&int, &mut T) -> bool) {
85-
fail!(~"nope")
86-
}
87-
8884
fn insert(&mut self, k: int, _: T) -> bool {
8985
self.meows += k;
9086
true

0 commit comments

Comments
 (0)