Skip to content

feat(api)!: the two enum lists are spans over the tables - #892

Merged
andiwand merged 1 commit into
mainfrom
feat/table-lookups-return-span
Sep 13, 2026
Merged

andiwand merged 1 commit into
mainfrom
feat/table-lookups-return-span

Conversation

@andiwand

Copy link
Copy Markdown
Member

🤖 Generated with Claude Code

What

all_file_types() and all_text_encodings() allocated a std::vector on every call to project one column out of a constexpr table. Every other table lookup in odr.hpp returns a std::span<const …>, so these two were the outliers.

  • Each table projects its enum column at compile time (file_type_table::types(), text_encoding_table::encodings()).
  • The two public lookups return std::span<const …> and are noexcept.
  • python copies the span into a list, because pybind11 has no caster for a span. apple reads the span. jni and wasm iterate and need no change.
  • The test compares with std::ranges::equal, since a span has no operator==.

Breaking for a C++ consumer that binds the result to a std::vector. Lands in v7.0.0 with the other API breaks; a changelog entry is included.

Checks

  • odr_test: the table and encoding suites pass.
  • jni JUnit, python pytest, the wasm node suite and the apple XCTest suite pass locally.
  • The touched translation units compile clean under Homebrew clang with -Wall -Wextra -Werror.

https://claude.ai/code/session_01QNQ2GtyAXXWGvnKBtwTEhQ

`all_file_types()` and `all_text_encodings()` allocated a vector on every
call to project one column out of a constexpr table. Each table now
projects that column at compile time, and the two lookups return a span
like every other table lookup in the header. The bindings still hand out
a list.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QNQ2GtyAXXWGvnKBtwTEhQ
@andiwand
andiwand merged commit 985a957 into main Sep 13, 2026
35 of 36 checks passed
@andiwand
andiwand deleted the feat/table-lookups-return-span branch September 13, 2026 08:35
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