Skip to content
This repository was archived by the owner on Jan 15, 2025. It is now read-only.

Conversation

@cgwalters
Copy link
Member

I was working on this area of code for a previous PR, and I almost
made a refactoring that shared the hexbuf. I think the stack
allocation here was a premature optimization. Let's just heap
allocate - modern allocators are fast with thread-local
storage and caches etc. The C side allocates a ton anyways.

However there is an optimization we can make here - by passing
ownership of the checksum string into the recursive dirtree walk,
we can drop it before recursing. Now there's only one heap
allocation there instead of it being O(depth).

I was working on this area of code for a previous PR, and I almost
made a refactoring that shared the `hexbuf`.  I think the stack
allocation here was a premature optimization.  Let's just heap
allocate - modern allocators are fast with thread-local
storage and caches etc.  The C side allocates a ton anyways.

However there is an optimization we can make here - by passing
ownership of the checksum string into the recursive dirtree walk,
we can drop it before recursing.   Now there's only one heap
allocation there instead of it being O(depth).
@cgwalters
Copy link
Member Author

I also did KokaKiwi/rust-hex#66

Copy link
Member

@jmarrero jmarrero left a comment

Choose a reason for hiding this comment

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

lgtm

@cgwalters cgwalters merged commit 9d7e6d4 into ostreedev:main Dec 20, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants