Skip to content

Make internal usage of uint32_t more explicit#131

Open
pgaskin wants to merge 2 commits intos-yata:masterfrom
pgaskin:grimoire-uint32
Open

Make internal usage of uint32_t more explicit#131
pgaskin wants to merge 2 commits intos-yata:masterfrom
pgaskin:grimoire-uint32

Conversation

@pgaskin
Copy link

@pgaskin pgaskin commented Nov 5, 2025

This change will not break the public API/ABI.

It only affects the data structures used internally which already contain unconditional asserts or narrowing casts for UINT32_MAX (but not the ones which have a MARISA_THROW_IF for a length_error).

Most of those already use uint32_t variables internally after the case, and only take/return size_t in the getters/setters.

Where lengths/indexes are computed at runtime, I continue to use size_t, then assert and cast it to a uint32_t afterwards. I also kept size_t for I/O.

I modified Vector/FlatVector to limit itself to UINT32_MAX instead of SIZE_MAX (and check it when reading) since it's already effectively limited to that anyways.

This will warn on things like implicitly converting a size_t to uint32_t.
@pgaskin pgaskin changed the title Use uint32_t instead of size_t internally Make internal usage of uint32_t more explicit Nov 5, 2025
@pgaskin pgaskin marked this pull request as ready for review November 5, 2025 17:57
This change will not break the public API/ABI.

It only affects the data structures used internally which already
contain unconditional asserts or narrowing casts for UINT32_MAX (but
not the ones which have a MARISA_THROW_IF for a length_error).

Most of those already use uint32_t variables internally after the case,
and only take/return size_t in the getters/setters.

Where lengths/indexes are computed at runtime, I continue to use
size_t, then assert and cast it to a uint32_t afterwards. I also kept
size_t for I/O.

I modified Vector/FlatVector to limit itself to UINT32_MAX instead of
SIZE_MAX (and check it when reading) since it's already effectively
limited to that anyways.
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.

1 participant