Skip to content

Commit 1dc9cc9

Browse files
committed
---
yaml --- r: 140630 b: refs/heads/try2 c: 936c07d h: refs/heads/master v: v3
1 parent b52fbd6 commit 1dc9cc9

File tree

2 files changed

+21
-25
lines changed

2 files changed

+21
-25
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: c02064d153dccb2d66c5158e0c7eeb6a8bbca0f5
8+
refs/heads/try2: 936c07dcf0137b7ef456e82b9e70c3a2743dbe16
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/libstd/base64.rs

Lines changed: 20 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -156,31 +156,27 @@ impl FromBase64 for ~[u8] {
156156
let ch = self[i] as char;
157157
n <<= 6u;
158158
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")
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+
}
181178
}
182-
} else {
183-
fail!(~"invalid base64 character");
179+
_ => fail!(~"invalid base64 character")
184180
}
185181
186182
i += 1u;

0 commit comments

Comments
 (0)