Skip to content

Commit bce47a1

Browse files
brsongraydon
authored andcommitted
---
yaml --- r: 1520 b: refs/heads/master c: 330c9c6 h: refs/heads/master v: v3
1 parent 5d99d43 commit bce47a1

File tree

2 files changed

+4
-19
lines changed

2 files changed

+4
-19
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: 138c55a69d44371e4de04ed538c787dec46a7200
2+
refs/heads/master: 330c9c6c3592496462dbf9aa716a37e048b00172

trunk/src/lib/_str.rs

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -96,25 +96,10 @@ fn buf(str s) -> sbuf {
9696
}
9797

9898
fn bytes(str s) -> vec[u8] {
99-
/* FIXME (issue #58):
100-
* Should be...
101-
*
102-
* fn ith(str s, uint i) -> u8 {
103-
* ret s.(i);
104-
* }
105-
* ret _vec.init_fn[u8](bind ith(s, _), byte_len(s));
106-
*
107-
* but we do not correctly decrement refcount of s when
108-
* the binding dies, so we have to do this manually.
109-
*/
110-
let uint n = _str.byte_len(s);
111-
let vec[u8] v = _vec.alloc[u8](n);
112-
let uint i = 0u;
113-
while (i < n) {
114-
v += vec(s.(i));
115-
i += 1u;
99+
fn ith(str s, uint i) -> u8 {
100+
ret s.(i);
116101
}
117-
ret v;
102+
ret _vec.init_fn[u8](bind ith(s, _), byte_len(s));
118103
}
119104

120105
fn from_bytes(vec[u8] v) : is_utf8(v) -> str {

0 commit comments

Comments
 (0)