Skip to content

Conversation

@heoh
Copy link
Contributor

@heoh heoh commented Oct 24, 2025

Description

This PR consolidates two similar string manipulation functions in tokenizer.c:

  • _str_copy_decimal_str_c: handled decimal/thousands separator replacement with heap allocation
  • copy_string_without_char: removed characters with caller-provided buffer

The refactored _str_copy_decimal_str_c now combines the strengths of both approaches:

  • Uses caller-provided stack buffer (no heap allocation needed)
  • Processes multiple character replacements
  • Uses block memory operations (strspn, memcpy) instead of byte-by-byte processing
  • Provides comprehensive validation and error handling

Changes

  • Refactored _str_copy_decimal_str_c to write to caller-provided buffer instead of heap allocation
  • Added helper functions and macros (str_consume_span, etc.) for efficient string parsing
  • Removed copy_string_without_char function
  • Updated str_to_int64 and str_to_uint64 to use the refactored function
  • Simplified round_trip function with stack buffer allocation

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.

Consolidate decimal digit -> str functions in tokenizer.c

1 participant