File tree 1 file changed +10
-1
lines changed
1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -1064,15 +1064,24 @@ pub mod raw {
1064
1064
}
1065
1065
1066
1066
/// Appends a byte to a string. (Not UTF-8 safe).
1067
+ #[ cfg( stage0) ]
1067
1068
pub unsafe fn push_byte ( s : & mut ~str , b : u8 ) {
1068
1069
let new_len = s. len ( ) + 1 ;
1069
1070
s. reserve_at_least ( new_len) ;
1070
1071
do s. as_mut_buf |buf, len| {
1071
- * ptr:: mut_offset ( buf, ( len- 1 ) as int ) = b;
1072
+ * ptr:: mut_offset ( buf, len as int ) = b;
1072
1073
}
1073
1074
set_len( & mut * s, new_len) ;
1074
1075
}
1075
1076
1077
+ /// Appends a byte to a string. (Not UTF-8 safe).
1078
+ #[ cfg( not( stage0) ) ]
1079
+ #[ inline]
1080
+ pub unsafe fn push_byte ( s : & mut ~str , b : u8 ) {
1081
+ let v: & mut ~[ u8 ] = cast:: transmute ( s) ;
1082
+ v. push ( b) ;
1083
+ }
1084
+
1076
1085
/// Appends a vector of bytes to a string. (Not UTF-8 safe).
1077
1086
unsafe fn push_bytes ( s : & mut ~str , bytes : & [ u8 ] ) {
1078
1087
let new_len = s. len ( ) + bytes. len ( ) ;
You can’t perform that action at this time.
0 commit comments