Refactor repetitive method calls and standardize UChar buffer retry logic#359
Refactor repetitive method calls and standardize UChar buffer retry logic#359filmil wants to merge 1 commit into
Conversation
This commit reduces code repetition across several crates by introducing a centralized `buffered_uchar_method_with_retry` function in the `rust_icu_ustring` crate. This function abstracts the common ICU pattern of preflighting a buffer, resizing, and retrying on overflow. Modified Crates: - `rust_icu_ustring`: Added the `buffered_uchar_method_with_retry` helper. - `rust_icu_ulistformatter`: Refactored to use a more flexible `generate_format_methods!` macro and the new global helper. - `rust_icu_udat`: Replaced manual retry loops in `format` and timezone helpers with the new standardized function. - `rust_icu_umsg`: Updated `format_args` to leverage the new helper. - `rust_icu_upluralrules`: Simplified the `select` method for consistency. This refactoring improves maintainability, reduces the surface area for manual memory/buffer handling errors, and establishes a consistent pattern across the workspace. This commit was created by an automated coding assistant, with human supervision. Co-authored-by: filmil <246576+filmil@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
Refactored the codebase to reduce code repetition and standardize the handling of ICU's buffer-resize-retry pattern for
UCharstrings.Key Changes:
buffered_uchar_method_with_retrytorust_icu_ustring, providing a closure-based alternative to the existing macro for better flexibility.ulistformatter: Introduced a more robustgenerate_format_methods!macro and removed repetitive manual implementations.udat,umsg, andupluralrulesto use the new standardized pattern, eliminating many lines of manual boilerplate.vec![0; capacity]before use, avoiding potential safety issues with uninitialized memory.PR created automatically by Jules for task 2703538365688145281 started by @filmil