Skip to content

Commit 21c2727

Browse files
committed
---
yaml --- r: 140625 b: refs/heads/try2 c: 9a292b3 h: refs/heads/master i: 140623: 34301ce v: v3
1 parent 7dfb132 commit 21c2727

File tree

10 files changed

+42
-38
lines changed

10 files changed

+42
-38
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: 101d4bf8b2a9d7bf7cd537ae8a9d9a9a12ebc150
8+
refs/heads/try2: 9a292b3da5585f0230ed5d0e198531b87633b832
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/libcore/at_vec.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ pub fn build_sized_opt<A>(size: Option<uint>,
102102
#[inline(always)]
103103
pub fn append<T:Copy>(lhs: @[T], rhs: &const [T]) -> @[T] {
104104
do build_sized(lhs.len() + rhs.len()) |push| {
105-
for vec::each(lhs) |x| { push(*x); }
105+
for lhs.each |x| { push(*x); }
106106
for uint::range(0, rhs.len()) |i| { push(rhs[i]); }
107107
}
108108
}
@@ -111,7 +111,7 @@ pub fn append<T:Copy>(lhs: @[T], rhs: &const [T]) -> @[T] {
111111
/// Apply a function to each element of a vector and return the results
112112
pub fn map<T, U>(v: &[T], f: &fn(x: &T) -> U) -> @[U] {
113113
do build_sized(v.len()) |push| {
114-
for vec::each(v) |elem| {
114+
for v.each |elem| {
115115
push(f(elem));
116116
}
117117
}

branches/try2/src/libcore/either.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ pub fn lefts<T:Copy,U>(eithers: &[Either<T, U>]) -> ~[T] {
4444
//! Extracts from a vector of either all the left values
4545
4646
do vec::build_sized(eithers.len()) |push| {
47-
for vec::each(eithers) |elt| {
47+
for eithers.each |elt| {
4848
match *elt {
4949
Left(ref l) => { push(*l); }
5050
_ => { /* fallthrough */ }
@@ -57,7 +57,7 @@ pub fn rights<T, U: Copy>(eithers: &[Either<T, U>]) -> ~[U] {
5757
//! Extracts from a vector of either all the right values
5858
5959
do vec::build_sized(eithers.len()) |push| {
60-
for vec::each(eithers) |elt| {
60+
for eithers.each |elt| {
6161
match *elt {
6262
Right(ref r) => { push(*r); }
6363
_ => { /* fallthrough */ }

branches/try2/src/libcore/hash.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ impl Streaming for SipState {
378378
fn result_str(&mut self) -> ~str {
379379
let r = self.result_bytes();
380380
let mut s = ~"";
381-
for vec::each(r) |b| {
381+
for r.each |b| {
382382
s += uint::to_str_radix(*b as uint, 16u);
383383
}
384384
s
@@ -478,7 +478,7 @@ mod tests {
478478

479479
fn to_hex_str(r: &[u8, ..8]) -> ~str {
480480
let mut s = ~"";
481-
for vec::each(*r) |b| {
481+
for (*r).each |b| {
482482
s += uint::to_str_radix(*b as uint, 16u);
483483
}
484484
s

branches/try2/src/libcore/io.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1200,7 +1200,7 @@ pub fn mk_file_writer(path: &Path, flags: &[FileFlag])
12001200
fn wb() -> c_int { O_WRONLY as c_int }
12011201

12021202
let mut fflags: c_int = wb();
1203-
for vec::each(flags) |f| {
1203+
for flags.each |f| {
12041204
match *f {
12051205
Append => fflags |= O_APPEND as c_int,
12061206
Create => fflags |= O_CREAT as c_int,

branches/try2/src/libcore/os.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1491,7 +1491,7 @@ mod tests {
14911491
fn test_env_getenv() {
14921492
let e = env();
14931493
assert!(vec::len(e) > 0u);
1494-
for vec::each(e) |p| {
1494+
for e.each |p| {
14951495
let (n, v) = copy *p;
14961496
debug!(copy n);
14971497
let v2 = getenv(n);
@@ -1583,7 +1583,7 @@ mod tests {
15831583
// Just assuming that we've got some contents in the current directory
15841584
assert!((vec::len(dirs) > 0u));
15851585
1586-
for vec::each(dirs) |dir| {
1586+
for dirs.each |dir| {
15871587
debug!(copy *dir);
15881588
}
15891589
}

branches/try2/src/libcore/result.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ pub fn map_vec<T,U:Copy,V:Copy>(
300300
ts: &[T], op: &fn(&T) -> Result<V,U>) -> Result<~[V],U> {
301301
302302
let mut vs: ~[V] = vec::with_capacity(vec::len(ts));
303-
for vec::each(ts) |t| {
303+
for ts.each |t| {
304304
match op(t) {
305305
Ok(copy v) => vs.push(v),
306306
Err(copy u) => return Err(u)

branches/try2/src/libcore/run.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ fn with_argv<T>(prog: &str, args: &[~str],
426426
cb: &fn(**libc::c_char) -> T) -> T {
427427
let mut argptrs = str::as_c_str(prog, |b| ~[b]);
428428
let mut tmps = ~[];
429-
for vec::each(args) |arg| {
429+
for args.each |arg| {
430430
let t = @copy *arg;
431431
tmps.push(t);
432432
argptrs.push_all(str::as_c_str(*t, |b| ~[b]));
@@ -445,7 +445,7 @@ fn with_envp<T>(env: &Option<~[(~str,~str)]>,
445445
let mut tmps = ~[];
446446
let mut ptrs = ~[];
447447

448-
for vec::each(*es) |e| {
448+
for (*es).each |e| {
449449
let (k,v) = copy *e;
450450
let t = @(fmt!("%s=%s", k, v));
451451
tmps.push(t);
@@ -470,7 +470,7 @@ fn with_envp<T>(env: &Option<~[(~str,~str)]>,
470470
match *env {
471471
Some(ref es) if !vec::is_empty(*es) => {
472472
let mut blk : ~[u8] = ~[];
473-
for vec::each(*es) |e| {
473+
for (*es).each |e| {
474474
let (k,v) = copy *e;
475475
let t = fmt!("%s=%s", k, v);
476476
let mut v : ~[u8] = ::cast::transmute(t);

branches/try2/src/libcore/str.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ pub fn from_char(ch: char) -> ~str {
189189
pub fn from_chars(chs: &[char]) -> ~str {
190190
let mut buf = ~"";
191191
reserve(&mut buf, chs.len());
192-
for vec::each(chs) |ch| {
192+
for chs.each |ch| {
193193
push_char(&mut buf, *ch);
194194
}
195195
buf
@@ -326,7 +326,7 @@ pub fn connect_slices(v: &[&str], sep: &str) -> ~str {
326326
do as_buf(sep) |sepbuf, seplen| {
327327
let seplen = seplen - 1;
328328
let mut buf = ::cast::transmute_mut_unsafe(buf);
329-
for vec::each(v) |ss| {
329+
for v.each |ss| {
330330
do as_buf(*ss) |ssbuf, sslen| {
331331
let sslen = sslen - 1;
332332
if first {
@@ -2407,7 +2407,7 @@ pub mod raw {
24072407
unsafe fn push_bytes(s: &mut ~str, bytes: &[u8]) {
24082408
let new_len = s.len() + bytes.len();
24092409
reserve_at_least(&mut *s, new_len);
2410-
for vec::each(bytes) |byte| { push_byte(&mut *s, *byte); }
2410+
for bytes.each |byte| { push_byte(&mut *s, *byte); }
24112411
}
24122412

24132413
/// Removes the last byte from a string and returns it. (Not UTF-8 safe).
@@ -3782,7 +3782,7 @@ mod tests {
37823782
0xd801_u16, 0xdc95_u16, 0xd801_u16, 0xdc86_u16,
37833783
0x000a_u16 ]) ];
37843784

3785-
for vec::each(pairs) |p| {
3785+
for pairs.each |p| {
37863786
let (s, u) = copy *p;
37873787
assert!(to_utf16(s) == u);
37883788
assert!(from_utf16(u) == s);

branches/try2/src/libstd/base64.rs

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -156,27 +156,31 @@ impl FromBase64 for ~[u8] {
156156
let ch = self[i] as char;
157157
n <<= 6u;
158158
159-
match ch {
160-
'A'..'Z' => n |= (ch as uint) - 0x41,
161-
'a'..'z' => n |= (ch as uint) - 0x47,
162-
'0'..'9' => n |= (ch as uint) + 0x04,
163-
'+' => n |= 0x3E,
164-
'/' => n |= 0x3F,
165-
'=' => {
166-
match len - i {
167-
1u => {
168-
r.push(((n >> 16u) & 0xFFu) as u8);
169-
r.push(((n >> 8u ) & 0xFFu) as u8);
170-
return copy r;
171-
}
172-
2u => {
173-
r.push(((n >> 10u) & 0xFFu) as u8);
174-
return copy r;
175-
}
176-
_ => fail!(~"invalid base64 padding")
177-
}
159+
if ch >= 'A' && ch <= 'Z' {
160+
n |= (ch as uint) - 0x41u;
161+
} else if ch >= 'a' && ch <= 'z' {
162+
n |= (ch as uint) - 0x47u;
163+
} else if ch >= '0' && ch <= '9' {
164+
n |= (ch as uint) + 0x04u;
165+
} else if ch == '+' {
166+
n |= 0x3Eu;
167+
} else if ch == '/' {
168+
n |= 0x3Fu;
169+
} else if ch == '=' {
170+
match len - i {
171+
1u => {
172+
r.push(((n >> 16u) & 0xFFu) as u8);
173+
r.push(((n >> 8u ) & 0xFFu) as u8);
174+
return copy r;
175+
}
176+
2u => {
177+
r.push(((n >> 10u) & 0xFFu) as u8);
178+
return copy r;
179+
}
180+
_ => fail!(~"invalid base64 padding")
178181
}
179-
_ => fail!(~"invalid base64 character")
182+
} else {
183+
fail!(~"invalid base64 character");
180184
}
181185
182186
i += 1u;

0 commit comments

Comments
 (0)