Skip to content

Commit 5cdc4ea

Browse files
committed
---
yaml --- r: 57196 b: refs/heads/try c: 106fd12 h: refs/heads/master v: v3
1 parent 4494c52 commit 5cdc4ea

File tree

12 files changed

+50
-75
lines changed

12 files changed

+50
-75
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
refs/heads/master: c081ffbd1e845687202a975ea2e698b623e5722f
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 79a2b2eafc3c766cecec8a5f76317693bae9ed17
5-
refs/heads/try: d53e686f4f940ff87cc8bff3a2ebe81cc4022208
5+
refs/heads/try: 106fd12423491625b78326a2d2055d7e1d43464f
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c

branches/try/src/libcore/iterator.rs

Lines changed: 8 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -312,19 +312,6 @@ impl<A, T: Iterator<A>> Iterator<A> for TakeIterator<T> {
312312
}
313313
}
314314

315-
pub struct ScanIterator<'self, A, B, T, St> {
316-
priv iter: T,
317-
priv f: &'self fn(&mut St, A) -> Option<B>,
318-
state: St
319-
}
320-
321-
impl<'self, A, B, T: Iterator<A>, St> Iterator<B> for ScanIterator<'self, A, B, T, St> {
322-
#[inline]
323-
fn next(&mut self) -> Option<B> {
324-
self.iter.next().chain(|a| (self.f)(&mut self.state, a))
325-
}
326-
}
327-
328315
pub struct UnfoldrIterator<'self, A, St> {
329316
priv f: &'self fn(&mut St) -> Option<A>,
330317
state: St
@@ -348,25 +335,16 @@ impl<'self, A, St> Iterator<A> for UnfoldrIterator<'self, A, St> {
348335
}
349336
}
350337

351-
/// An infinite iterator starting at `start` and advancing by `step` with each iteration
352-
pub struct Counter<A> {
353-
state: A,
354-
step: A
355-
}
356-
357-
pub impl<A> Counter<A> {
358-
#[inline(always)]
359-
fn new(start: A, step: A) -> Counter<A> {
360-
Counter{state: start, step: step}
361-
}
338+
pub struct ScanIterator<'self, A, B, T, St> {
339+
priv iter: T,
340+
priv f: &'self fn(&mut St, A) -> Option<B>,
341+
state: St
362342
}
363343

364-
impl<A: Add<A, A> + Clone> Iterator<A> for Counter<A> {
365-
#[inline(always)]
366-
fn next(&mut self) -> Option<A> {
367-
let result = self.state.clone();
368-
self.state = self.state.add(&self.step); // FIXME: #6050
369-
Some(result)
344+
impl<'self, A, B, T: Iterator<A>, St> Iterator<B> for ScanIterator<'self, A, B, T, St> {
345+
#[inline]
346+
fn next(&mut self) -> Option<B> {
347+
self.iter.next().chain(|a| (self.f)(&mut self.state, a))
370348
}
371349
}
372350

@@ -375,13 +353,6 @@ mod tests {
375353
use super::*;
376354
use prelude::*;
377355

378-
#[test]
379-
fn test_counter_to_vec() {
380-
let mut it = Counter::new(0, 5).take(10);
381-
let xs = iter::iter_to_vec(|f| it.advance(f));
382-
assert_eq!(xs, ~[0, 5, 10, 15, 20, 25, 30, 35, 40, 45]);
383-
}
384-
385356
#[test]
386357
fn test_iterator_chain() {
387358
let xs = [0u, 1, 2, 3, 4, 5];

branches/try/src/libcore/result.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ pub fn map_vec2<S,T,U:Copy,V:Copy>(ss: &[S], ts: &[T],
358358
359359
/**
360360
* Applies op to the pairwise elements from `ss` and `ts`, aborting on
361-
* error. This could be implemented using `map_zip()` but it is more efficient
361+
* error. This could be implemented using `map2()` but it is more efficient
362362
* on its own as no result vector is built.
363363
*/
364364
#[inline(always)]

branches/try/src/libcore/tuple.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ impl<'self,A:Copy,B:Copy> ExtendedTupleOps<A,B> for (&'self [A], &'self [B]) {
123123
fn map<C>(&self, f: &fn(a: &A, b: &B) -> C) -> ~[C] {
124124
match *self {
125125
(ref a, ref b) => {
126-
vec::map_zip(*a, *b, f)
126+
vec::map2(*a, *b, f)
127127
}
128128
}
129129
}
@@ -144,7 +144,7 @@ impl<A:Copy,B:Copy> ExtendedTupleOps<A,B> for (~[A], ~[B]) {
144144
fn map<C>(&self, f: &fn(a: &A, b: &B) -> C) -> ~[C] {
145145
match *self {
146146
(ref a, ref b) => {
147-
vec::map_zip(*a, *b, f)
147+
vec::map2(*a, *b, f)
148148
}
149149
}
150150
}

branches/try/src/libcore/vec.rs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -847,11 +847,8 @@ pub fn flat_map<T, U>(v: &[T], f: &fn(t: &T) -> ~[U]) -> ~[U] {
847847
result
848848
}
849849
850-
/**
851-
* Apply a function to each pair of elements and return the results.
852-
* Equivalent to `map(zip(v0, v1), f)`.
853-
*/
854-
pub fn map_zip<T:Copy,U:Copy,V>(v0: &[T], v1: &[U],
850+
/// Apply a function to each pair of elements and return the results
851+
pub fn map2<T:Copy,U:Copy,V>(v0: &[T], v1: &[U],
855852
f: &fn(t: &T, v: &U) -> V) -> ~[V] {
856853
let v0_len = len(v0);
857854
if v0_len != len(v1) { fail!(); }
@@ -3399,12 +3396,12 @@ mod tests {
33993396
}
34003397

34013398
#[test]
3402-
fn test_map_zip() {
3399+
fn test_map2() {
34033400
fn times(x: &int, y: &int) -> int { *x * *y }
34043401
let f = times;
34053402
let v0 = ~[1, 2, 3, 4, 5];
34063403
let v1 = ~[5, 4, 3, 2, 1];
3407-
let u = map_zip::<int, int, int>(v0, v1, f);
3404+
let u = map2::<int, int, int>(v0, v1, f);
34083405
let mut i = 0;
34093406
while i < 5 { assert!(v0[i] * v1[i] == u[i]); i += 1; }
34103407
}
@@ -4338,10 +4335,10 @@ mod tests {
43384335
#[ignore(windows)]
43394336
#[should_fail]
43404337
#[allow(non_implicitly_copyable_typarams)]
4341-
fn test_map_zip_fail() {
4338+
fn test_map2_fail() {
43424339
let v = [(~0, @0), (~0, @0), (~0, @0), (~0, @0)];
43434340
let mut i = 0;
4344-
do map_zip(v, v) |_elt1, _elt2| {
4341+
do map2(v, v) |_elt1, _elt2| {
43454342
if i == 2 {
43464343
fail!()
43474344
}

branches/try/src/librustc/middle/trans/monomorphize.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ pub fn make_mono_id(ccx: @CrateContext,
356356
Some(vts) => {
357357
let item_ty = ty::lookup_item_type(ccx.tcx, item);
358358
let mut i = 0;
359-
vec::map_zip(*item_ty.generics.type_param_defs, substs, |type_param_def, subst| {
359+
vec::map2(*item_ty.generics.type_param_defs, substs, |type_param_def, subst| {
360360
let mut v = ~[];
361361
for type_param_def.bounds.each |bound| {
362362
match *bound {
@@ -376,7 +376,7 @@ pub fn make_mono_id(ccx: @CrateContext,
376376
};
377377
let param_ids = match param_uses {
378378
Some(ref uses) => {
379-
vec::map_zip(precise_param_ids, **uses, |id, uses| {
379+
vec::map2(precise_param_ids, **uses, |id, uses| {
380380
if ccx.sess.no_monomorphic_collapse() {
381381
match copy *id {
382382
(a, b) => mono_precise(a, b)

branches/try/src/librustdoc/attr_pass.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ fn merge_method_attrs(
209209
}
210210
};
211211
212-
do vec::map_zip(docs, attrs) |doc, attrs| {
212+
do vec::map2(docs, attrs) |doc, attrs| {
213213
assert!(doc.name == attrs.first());
214214
let desc = attrs.second();
215215

branches/try/src/libsyntax/ext/deriving/generic.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -629,7 +629,7 @@ impl<'self> MethodDef<'self> {
629629
}
630630
}
631631
let field_tuples =
632-
do vec::map_zip(*self_vec,
632+
do vec::map2(*self_vec,
633633
enum_matching_fields) |&(id, self_f), &other| {
634634
(id, self_f, other)
635635
};

branches/try/src/libsyntax/ext/pipes/pipec.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ impl gen_send for message {
5757
assert!(next_state.tys.len() ==
5858
next.generics.ty_params.len());
5959
let arg_names = tys.mapi(|i, _ty| cx.ident_of(~"x_"+i.to_str()));
60-
let args_ast = vec::map_zip(arg_names, *tys, |n, t| cx.arg(*n, *t));
60+
let args_ast = vec::map2(arg_names, *tys, |n, t| cx.arg(*n, *t));
6161

6262
let pipe_ty = cx.ty_path_ast_builder(
6363
path(~[this.data_name()], span)
@@ -135,7 +135,7 @@ impl gen_send for message {
135135
debug!("pipec: no next state");
136136
let arg_names = tys.mapi(|i, _ty| (~"x_" + i.to_str()));
137137
138-
let args_ast = do vec::map_zip(arg_names, *tys) |n, t| {
138+
let args_ast = do vec::map2(arg_names, *tys) |n, t| {
139139
cx.arg(cx.ident_of(*n), *t)
140140
};
141141

branches/try/src/libsyntax/ext/tt/transcribe.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ use core::hashmap::HashMap;
2222
use core::option;
2323
use core::vec;
2424

25+
/* FIXME #2811: figure out how to have a uniquely linked stack, and change to
26+
`~` */
2527
///an unzipping of `token_tree`s
2628
struct TtFrame {
2729
forest: @mut ~[ast::token_tree],

branches/try/src/rt/isaac/randport.cpp

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ rand.c: By Bob Jenkins. My random number generator, ISAAC. Public Domain
66
970719: use context, not global variables, for internal state
77
980324: make a portable version
88
010626: Note this is public domain
9+
100725: Mask on use of >32 bits, not on assignment: from Paul Eggert
910
------------------------------------------------------------------------------
1011
*/
1112
#ifndef STANDARD
@@ -27,37 +28,37 @@ rand.c: By Bob Jenkins. My random number generator, ISAAC. Public Domain
2728

2829
void isaac(randctx *ctx)
2930
{
30-
register ub4 a,b,x,y,*m,*mm,*m2,*r,*mend;
31+
ub4 a,b,x,y,*m,*mm,*m2,*r,*mend;
3132
mm=ctx->randmem; r=ctx->randrsl;
32-
a = ctx->randa; b = (ctx->randb + (++ctx->randc)) & 0xffffffff;
33+
a = ctx->randa; b = ctx->randb + (++ctx->randc);
3334
for (m = mm, mend = m2 = m+(RANDSIZ/2); m<mend; )
3435
{
3536
rngstep( a<<13, a, b, mm, m, m2, r, x);
36-
rngstep( a>>6 , a, b, mm, m, m2, r, x);
37+
rngstep( (a & 0xffffffff) >>6 , a, b, mm, m, m2, r, x);
3738
rngstep( a<<2 , a, b, mm, m, m2, r, x);
38-
rngstep( a>>16, a, b, mm, m, m2, r, x);
39+
rngstep( (a & 0xffffffff) >>16, a, b, mm, m, m2, r, x);
3940
}
4041
for (m2 = mm; m2<mend; )
4142
{
4243
rngstep( a<<13, a, b, mm, m, m2, r, x);
43-
rngstep( a>>6 , a, b, mm, m, m2, r, x);
44+
rngstep( (a & 0xffffffff) >>6 , a, b, mm, m, m2, r, x);
4445
rngstep( a<<2 , a, b, mm, m, m2, r, x);
45-
rngstep( a>>16, a, b, mm, m, m2, r, x);
46+
rngstep( (a & 0xffffffff) >>16, a, b, mm, m, m2, r, x);
4647
}
4748
ctx->randb = b; ctx->randa = a;
4849
}
4950

5051

5152
#define mix(a,b,c,d,e,f,g,h) \
5253
{ \
53-
a^=b<<11; d+=a; b+=c; \
54-
b^=c>>2; e+=b; c+=d; \
55-
c^=d<<8; f+=c; d+=e; \
56-
d^=e>>16; g+=d; e+=f; \
57-
e^=f<<10; h+=e; f+=g; \
58-
f^=g>>4; a+=f; g+=h; \
59-
g^=h<<8; b+=g; h+=a; \
60-
h^=a>>9; c+=h; a+=b; \
54+
a^=b<<11; d+=a; b+=c; \
55+
b^=(c&0xffffffff)>>2; e+=b; c+=d; \
56+
c^=d<<8; f+=c; d+=e; \
57+
d^=(e&0xffffffff)>>16; g+=d; e+=f; \
58+
e^=f<<10; h+=e; f+=g; \
59+
f^=(g&0xffffffff)>>4; a+=f; g+=h; \
60+
g^=h<<8; b+=g; h+=a; \
61+
h^=(a&0xffffffff)>>9; c+=h; a+=b; \
6162
}
6263

6364
/* if (flag==TRUE), then use the contents of randrsl[] to initialize mm[]. */
@@ -81,17 +82,21 @@ void randinit(randctx *ctx, word flag)
8182
/* initialize using the contents of r[] as the seed */
8283
for (i=0; i<RANDSIZ; i+=8)
8384
{
84-
a+=r[i ]; b+=r[i+1]; c+=r[i+2]; d+=r[i+3];
85-
e+=r[i+4]; f+=r[i+5]; g+=r[i+6]; h+=r[i+7];
85+
a+=r[i ]; b+=r[i+1];
86+
c+=r[i+2]; d+=r[i+3];
87+
e+=r[i+4]; f+=r[i+5];
88+
g+=r[i+6]; h+=r[i+7];
8689
mix(a,b,c,d,e,f,g,h);
8790
m[i ]=a; m[i+1]=b; m[i+2]=c; m[i+3]=d;
8891
m[i+4]=e; m[i+5]=f; m[i+6]=g; m[i+7]=h;
8992
}
9093
/* do a second pass to make all of the seed affect all of m */
9194
for (i=0; i<RANDSIZ; i+=8)
9295
{
93-
a+=m[i ]; b+=m[i+1]; c+=m[i+2]; d+=m[i+3];
94-
e+=m[i+4]; f+=m[i+5]; g+=m[i+6]; h+=m[i+7];
96+
a+=m[i ]; b+=m[i+1];
97+
c+=m[i+2]; d+=m[i+3];
98+
e+=m[i+4]; f+=m[i+5];
99+
g+=m[i+6]; h+=m[i+7];
95100
mix(a,b,c,d,e,f,g,h);
96101
m[i ]=a; m[i+1]=b; m[i+2]=c; m[i+3]=d;
97102
m[i+4]=e; m[i+5]=f; m[i+6]=g; m[i+7]=h;

branches/try/src/test/run-pass/block-vec-map_zip.rs renamed to branches/try/src/test/run-pass/block-vec-map2.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ extern mod std;
1212

1313
pub fn main() {
1414
let v =
15-
vec::map_zip(~[1, 2, 3, 4, 5],
15+
vec::map2(~[1, 2, 3, 4, 5],
1616
~[true, false, false, true, true],
1717
|i, b| if *b { -(*i) } else { *i } );
1818
error!(v.clone());

0 commit comments

Comments
 (0)