Avoid reallocation in emit_bit
#39
Labels
No labels
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: TOPIO/BigWhoop#39
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
We could spare the reallocation in
emit_bit
if thestream
is guaranteed to have the correct size. The only usage ofemit_bit
is taking theheader
variable increate_packet
of tier2. Thememory
ofheader
is initially allocated to PACKET_HEADER_SIZE=512.A test that used two times the
PACKET_HEADER_SIZE
could avoid reallocation inemit_bit
.Generally,
PACKET_HEADER_SIZE
is variable and would have to be calculated to avoid dynamic reallocation.How could we do such a calculation?
Avoid reallocation in emit_bitto Avoid reallocation inemit_bit
In principal the max. header size should have an upper limit for a precinct of maximum size and number of codeblocks where every codeblock contributes to that packet. I'd have to check if that is actually the case but if true we could simply allocate a MAX_PACKET_HEADER_SIZE and reallocate once the header has been assembled. Alternatively we could forgo the reallocation and simply write out the packet header portion of the allocated memory block to the codestream once it is needed. However this would increase the memory footprint of the library.