1
Fork 0

More perf tweaks (issue #2719)

This commit is contained in:
Eric Holk 2012-06-26 11:13:02 -07:00
parent 51468b65a4
commit a08281616f
6 changed files with 70 additions and 21 deletions

View file

@ -122,7 +122,7 @@ Convert a vector of bytes to a UTF-8 string
Fails if invalid UTF-8
"]
pure fn from_bytes(vv: [u8]/~) -> str {
pure fn from_bytes(+vv: [u8]/~) -> str {
assert is_utf8(vv);
ret unsafe { unsafe::from_bytes(vv) };
}
@ -1750,9 +1750,9 @@ mod unsafe {
Does not verify that the vector contains valid UTF-8.
"]
unsafe fn from_bytes(v: [const u8]/~) -> str {
unsafe fn from_bytes(+v: [const u8]/~) -> str {
unsafe {
let mut vcopy = ::unsafe::transmute(copy v);
let mut vcopy = ::unsafe::transmute(v);
vec::push(vcopy, 0u8);
::unsafe::transmute(vcopy)
}