Skip to content

Commit 94c3975

Browse files
committed
libcore: str::push_char should use str::unsafe::set_len.
1 parent 0e1a4a4 commit 94c3975

File tree

1 file changed

+1
-6
lines changed

1 file changed

+1
-6
lines changed

src/libcore/str.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -220,14 +220,9 @@ fn push_char(&s: ~str, ch: char) {
220220
*ptr::mut_offset(buf, off + 5u) =
221221
(code & 63u | tag_cont) as u8;
222222
}
223-
*ptr::mut_offset(buf, off + nb) = 0u8;
224223
}
225224

226-
do as_bytes(s) |bytes| {
227-
let mut mut_bytes: ~[u8] = ::unsafe::reinterpret_cast(bytes);
228-
vec::unsafe::set_len(mut_bytes, new_len + 1u);
229-
::unsafe::forget(mut_bytes);
230-
}
225+
unsafe::set_len(s, new_len);
231226
}
232227
}
233228

0 commit comments

Comments
 (0)