File tree Expand file tree Collapse file tree 3 files changed +8
-14
lines changed Expand file tree Collapse file tree 3 files changed +8
-14
lines changed Original file line number Diff line number Diff line change @@ -117,7 +117,6 @@ export
117
117
118
118
#[ abi = "cdecl" ]
119
119
extern mod rustrt {
120
- fn rust_str_push ( & s: ~str , ch : u8 ) ;
121
120
fn str_reserve_shared ( & ss: ~str , nn : libc:: size_t ) ;
122
121
}
123
122
@@ -1998,12 +1997,18 @@ mod unsafe {
1998
1997
1999
1998
/// Appends a byte to a string. (Not UTF-8 safe).
2000
1999
unsafe fn push_byte ( & s: ~str , b : u8 ) {
2001
- rustrt:: rust_str_push ( s, b) ;
2000
+ reserve_at_least ( s, s. len ( ) + 1 ) ;
2001
+ do as_buf( s) |buf, len| {
2002
+ let buf: * mut u8 = :: unsafe:: reinterpret_cast ( buf) ;
2003
+ * ptr:: mut_offset ( buf, len) = b;
2004
+ }
2005
+ set_len( s, s. len ( ) + 1 ) ;
2002
2006
}
2003
2007
2004
2008
/// Appends a vector of bytes to a string. (Not UTF-8 safe).
2005
2009
unsafe fn push_bytes ( & s: ~str , bytes : ~[ u8 ] ) {
2006
- for vec:: each( bytes) |byte| { rustrt:: rust_str_push( s, byte) ; }
2010
+ reserve_at_least ( s, s. len ( ) + bytes. len ( ) ) ;
2011
+ for vec:: each( bytes) |byte| { push_byte( s, byte) ; }
2007
2012
}
2008
2013
2009
2014
/// Removes the last byte from a string and returns it. (Not UTF-8 safe).
Original file line number Diff line number Diff line change @@ -148,16 +148,6 @@ str_reserve_shared(rust_vec_box** sp,
148
148
reserve_vec_exact (task, sp, n_elts + 1 );
149
149
}
150
150
151
- extern " C" CDECL void
152
- rust_str_push (rust_vec_box** sp, uint8_t byte) {
153
- rust_task *task = rust_get_current_task ();
154
- size_t fill = (*sp)->body .fill ;
155
- reserve_vec (task, sp, fill + 1 );
156
- (*sp)->body .data [fill-1 ] = byte;
157
- (*sp)->body .data [fill] = 0 ;
158
- (*sp)->body .fill = fill + 1 ;
159
- }
160
-
161
151
extern " C" CDECL rust_vec*
162
152
rand_seed () {
163
153
size_t size = sizeof (ub4) * RANDSIZ;
Original file line number Diff line number Diff line change @@ -38,7 +38,6 @@ rust_getcwd
38
38
rust_get_stdin
39
39
rust_get_stdout
40
40
rust_get_stderr
41
- rust_str_push
42
41
rust_list_files
43
42
rust_log_console_on
44
43
rust_log_console_off
You can’t perform that action at this time.
0 commit comments