Skip to content

Refactor numeric metadata formatting in tonic conversion#144

Merged
RAprogramm merged 1 commit intonew_verisonfrom
eye-of-ra/refactor-metadata_value_to_ascii-for-performance
Sep 27, 2025
Merged

Refactor numeric metadata formatting in tonic conversion#144
RAprogramm merged 1 commit intonew_verisonfrom
eye-of-ra/refactor-metadata_value_to_ascii-for-performance

Conversation

@RAprogramm
Copy link
Owner

Summary

  • use reusable itoa/ryu buffers when serializing numeric metadata in the tonic converter
  • introduce helper types to pass stack-formatted strings into insert_ascii
  • add regression coverage to ensure numeric metadata text remains unchanged

Testing

  • cargo +nightly fmt --
  • cargo +1.90.0 clippy -- -D warnings
  • cargo +1.90.0 build --all-targets
  • cargo +1.90.0 test --all
  • cargo +1.90.0 doc --no-deps

https://chatgpt.com/codex/tasks/task_e_68d76c33757c832ba3c81e572d1bea8c

@RAprogramm RAprogramm merged commit 5c56ba4 into new_verison Sep 27, 2025
1 of 2 checks passed
@RAprogramm RAprogramm deleted the eye-of-ra/refactor-metadata_value_to_ascii-for-performance branch September 27, 2025 05:40
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting

Comment on lines +171 to +178
fn metadata_value_to_ascii<'a>(
value: &FieldValue,
formatter: &'a mut MetadataValueFormatter
) -> Option<MetadataAscii<'a>> {
match value {
FieldValue::Str(value) => {
let text = value.as_ref();
is_ascii_metadata_value(text).then_some(Cow::Borrowed(text))
is_ascii_metadata_value(text).then_some(MetadataAscii::Static(text))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P0] Accepting owned strings no longer compiles

The new MetadataAscii::Static arm assumes every FieldValue::Str is backed by a &'static str. However, FieldValue::Str stores a Cow<'static, str> and callers frequently pass owned Strings via field::str(...). For those owned cases value.as_ref() only yields a borrow tied to the field, and cannot be coerced to 'static, so this branch fails to compile once an owned string is encountered. Previously we returned a borrowed Cow<'_, str> which worked for both borrowed and owned strings. Please use an owned/buffer variant for dynamic strings instead of Static to keep the API usable.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant