Skip to content

perf(processors): eliminate redundant Tuple round-trip copies in case-transform processors - #240

Open
clockblocker wants to merge 1 commit into
queue/perf-named-tuple-traitsfrom
queue/perf-case-transform-zero-copy
Open

clockblocker wants to merge 1 commit into
queue/perf-named-tuple-traitsfrom
queue/perf-case-transform-zero-copy

Conversation

@clockblocker

@clockblocker clockblocker commented Dec 2, 2026 •

Copy link
Copy Markdown
Owner

AI-authored below this line.

Stacked on: #239 (queue/perf-named-tuple-traits)

Problem

All five field-casing processors rebuilt a NamedTuple through .transform(...) and intermediate field tuples across five duplicated headers.

That triggered redundant copies and moves on every field and blocked move-only fields altogether.

// Before (16-field rvalue): 32 copies + 80 moves via .transform() -> fields() -> make_from_tuple
return _named_tuple.transform([](const auto& _f) { return handle_one_field(_f); });

// After (16-field rvalue): 0 copies + 16 moves, constructing directly from values()
return NewNamedTuple(from_values_tuple, std::move(_named_tuple.values()));

Summary

  • Deduplicates all five casing headers into transform_named_tuple_case and constructs the renamed NamedTuple directly via internal from_values_tuple constructors.
  • Preserves xml_content, rfl::Rename, const fields, empty NamedTuple<>, and lvalue copy semantics while unlocking move-only fields.
  • Measured impact (refl-cpp-workbench#33):
    • Runtime (16-field rvalue): 32 -> 0 copies, 80 -> 16 moves.
    • Compile time: -20.2% (Clang) / -22.9% (GCC); -O0 binary size -77%.

OSS consumers

Consumer Location Pain point solved
hudson-trading/slang-server slang-server Eliminates tuple copies on camelCase/snake_case LSP structs.
openmoq/moqx ParsedConfig.h Avoids field-tuple round-trip copies in config serialization.
For Agents

…-transform processors

Construct the renamed NamedTuple directly from its identical Values tuple
via internal::from_values_tuple instead of round-tripping through
NamedTuple::transform -> fields() -> apply -> make_from_tuple across all
five case-transform processors:

- NamedTuple.hpp: add minimal internal::from_values_tuple_t tag and explicit
  NamedTuple(internal::from_values_tuple_t, Values&& / const Values&)
  constructors on both NamedTuple<FieldTypes...> and NamedTuple<>.
- internal/transform_case.hpp: add transform_case_field and
  transform_named_tuple_case (rvalue move and const-lvalue copy overloads)
  preserving xml_content, rfl::Rename, const fields, single-field nested
  NamedTuples, and empty NamedTuple<> behavior while enabling move-only
  field values.
- SnakeCaseToCamelCase.hpp, SnakeCaseToPascalCase.hpp,
  SnakeCaseToKebabCase.hpp, CamelCaseToSnakeCase.hpp, ToAllCaps.hpp:
  forward auto&& _named_tuple directly to transform_named_tuple_case.
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