Make std::istr::push_byte efficient
It used to allocate two (!) heap values per pushed byte. It now goes through a runtime function that simply grows the istr and writes the byte.
This commit is contained in:
@@ -243,6 +243,15 @@ vec_from_buf_shared(rust_task *task, type_desc *ty,
|
||||
return v;
|
||||
}
|
||||
|
||||
extern "C" CDECL void
|
||||
rust_istr_push(rust_task* task, rust_vec** sp, uint8_t byte) {
|
||||
size_t fill = (*sp)->fill;
|
||||
reserve_vec(task, sp, fill + 1);
|
||||
(*sp)->data[fill-1] = byte;
|
||||
(*sp)->data[fill] = 0;
|
||||
(*sp)->fill = fill + 1;
|
||||
}
|
||||
|
||||
extern "C" CDECL rust_str *
|
||||
str_from_cstr(rust_task *task, char *sbuf)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user