Skip to content

Commit f7cf0a5

Browse files
committed
---
yaml --- r: 58256 b: refs/heads/auto c: 936c07d h: refs/heads/master v: v3
1 parent d1fb39a commit f7cf0a5

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
@@ -14,6 +14,6 @@ refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0
1414
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
1515
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1616
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
17-
refs/heads/auto: c02064d153dccb2d66c5158e0c7eeb6a8bbca0f5
17+
refs/heads/auto: 936c07dcf0137b7ef456e82b9e70c3a2743dbe16
1818
refs/heads/servo: af82457af293e2a842ba6b7759b70288da276167
1919
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c

branches/auto/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)