Skip to content

Refactor c_buffer to make it suitable to re-use for a stack#70

Merged
dylanahsmith merged 2 commits into
masterfrom
c-buffer-refactor
Oct 6, 2020
Merged

Refactor c_buffer to make it suitable to re-use for a stack#70
dylanahsmith merged 2 commits into
masterfrom
c-buffer-refactor

Conversation

@dylanahsmith
Copy link
Copy Markdown
Contributor

Extracted from #59

  • I changed the c_buffer struct to store pointers for the end of the data and capacity, instead of storing the sizes and capacity directly. This is because we are mostly getting and updating the data end pointer, which is especially true in order to use this for the VM stack where we reserve space for the block and don't have to check the capacity for each write/push.
  • I've also added support to c_buffer to be initialized with size 0 (without an allocation) which is the one case where we can't just double the capacity until we have the requested extra capacity.

Copy link
Copy Markdown
Contributor

@peterzhu2118 peterzhu2118 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One minor comment, otherwise looks good!

Comment thread ext/liquid_c/vm_assembler.h
Base automatically changed from extract-vm-assembler to master October 6, 2020 12:41
Since this will avoid calculating the end pointer for each write, which
seems like it could become significant for the stack pointer.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants