sapphiredev / utilities

Common JavaScript utilities for Sapphire Projects
https://www.sapphirejs.dev/
MIT License
153 stars 39 forks source link

perf: implement fast word writing #787

Closed kyranet closed 1 month ago

kyranet commented 1 month ago

Writing values over 16 bits bit by bit is inefficient, especially when it's the word size of the buffer. This PR optimizes the code by writing the value in at most two operations, significantly improving the performance for large values.

This makes writing operations the size of a word or larger do 16 times fewer operations.

codecov[bot] commented 1 month ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 64.80%. Comparing base (c6f8a90) to head (6459798). Report is 2 commits behind head on main.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #787 +/- ## ========================================== + Coverage 64.74% 64.80% +0.06% ========================================== Files 257 257 Lines 8189 8203 +14 Branches 867 1492 +625 ========================================== + Hits 5302 5316 +14 Misses 2882 2882 Partials 5 5 ``` | [Flag](https://app.codecov.io/gh/sapphiredev/utilities/pull/787/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=sapphiredev) | Coverage Δ | | |---|---|---| | [18](https://app.codecov.io/gh/sapphiredev/utilities/pull/787/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=sapphiredev) | `64.80% <100.00%> (+0.06%)` | :arrow_up: | | [19](https://app.codecov.io/gh/sapphiredev/utilities/pull/787/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=sapphiredev) | `64.80% <100.00%> (+0.06%)` | :arrow_up: | | [20](https://app.codecov.io/gh/sapphiredev/utilities/pull/787/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=sapphiredev) | `64.80% <100.00%> (+0.06%)` | :arrow_up: | | [21](https://app.codecov.io/gh/sapphiredev/utilities/pull/787/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=sapphiredev) | `64.80% <100.00%> (+0.06%)` | :arrow_up: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=sapphiredev#carryforward-flags-in-the-pull-request-comment) to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.