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:
parent
14567c5eb0
commit
b099b1e3f7
4 changed files with 17 additions and 4 deletions
|
@ -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)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue