filecoin-project / go-amt-ipld

Implementation of an array mapped trie using go and ipld
Other
9 stars 15 forks source link

feat: shrink allocations when setting new elements #90

Closed Stebalien closed 4 months ago

Stebalien commented 4 months ago

bytes.Buffer will often over-allocate. Here, we copy to an exact-sized buffer to avoid this. We'll pay some extra copying cost, but we can at least avoid the allocation overhead with a buffer pool in most cases.

codecov-commenter commented 4 months ago

Codecov Report

Attention: Patch coverage is 83.33333% with 3 lines in your changes are missing coverage. Please review.

Project coverage is 53.32%. Comparing base (f6a28b2) to head (c64ccd1).

Additional details and impacted files [![Impacted file tree graph](https://app.codecov.io/gh/filecoin-project/go-amt-ipld/pull/90/graphs/tree.svg?width=650&height=150&src=pr&token=X9N1gLwHJY&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=filecoin-project)](https://app.codecov.io/gh/filecoin-project/go-amt-ipld/pull/90?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=filecoin-project) ```diff @@ Coverage Diff @@ ## master #90 +/- ## ========================================== + Coverage 52.94% 53.32% +0.38% ========================================== Files 13 13 Lines 1309 1324 +15 ========================================== + Hits 693 706 +13 - Misses 464 465 +1 - Partials 152 153 +1 ``` | [Files](https://app.codecov.io/gh/filecoin-project/go-amt-ipld/pull/90?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=filecoin-project) | Coverage Δ | | |---|---|---| | [amt.go](https://app.codecov.io/gh/filecoin-project/go-amt-ipld/pull/90?src=pr&el=tree&filepath=amt.go&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=filecoin-project#diff-YW10Lmdv) | `62.14% <66.66%> (ø)` | | | [util.go](https://app.codecov.io/gh/filecoin-project/go-amt-ipld/pull/90?src=pr&el=tree&filepath=util.go&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=filecoin-project#diff-dXRpbC5nbw==) | `90.00% <86.66%> (-10.00%)` | :arrow_down: |