-
Notifications
You must be signed in to change notification settings - Fork 15
Make InlineString
s have the same byte order as C-strings
#82
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
in order for an inline string to be C-compatible (last byte is always a null byte).
0a0fbbb
to
6b837b3
Compare
InlineString
s have the same byte order as C-strings
This adds a clean abstraction layer for all bit manipulation operations and updates the codebase to use these abstractions instead of raw bit operations. Key changes: - Add byte access functions: get_byte(), set_byte() - Add capacity management: get_capacity_byte(), set_capacity_byte() - Add data manipulation: get_string_data(), resize_string_data() - Add byte clearing: clear_suffix_bytes(), clear_prefix_bytes() - Update all functions to use abstractions instead of raw bit ops - Refactor addcodeunit() to use clean abstractions - Update constructors and type conversions to use abstractions All existing functionality maintained, 4495+ tests pass. Foundation for future C-compatibility improvements. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
…nversion to a pointer to pass into C-functions
6b837b3
to
9c6f48f
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #82 +/- ##
==========================================
+ Coverage 93.23% 93.62% +0.38%
==========================================
Files 3 3
Lines 636 690 +54
==========================================
+ Hits 593 646 +53
- Misses 43 44 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
I poked on this together with Claude to finish it up. The first commit is to add some abstractions, the second one actualyl does the byte order swap. Needs benchmarking etc. |
The point is that on master we have:
Instead, with this PR we store the capacity minus the length as the last byte (and not the length itself) leading to:
This means that in the case of the inline string being at full capacity the last byte double dips as a null terminator and showing that there is no capacity left (another way of saying that the length of the string is 3).
In order for "full C-compat" I think the byte order has to be swapped as well. I am not sure how worth this endeavour is tbh.