Repository navigation
perf(string): consolidate basic_string::write overloads (refs #3122 B5 / #2886 Stage 5) - #3152
Conversation
…5 / #2886 Stage 5) Three trivial delegates that previously each rebuilt a const char* pointer via an unnecessary static_cast<const void*> → bit_cast_ptr chain (write(u8*)) or address-of a single byte then bit_cast that (write(u8)) are now simple one-line tail-calls: write(const fl::u8* data, fl::size n) Drops the static_cast<const void*> intermediate; bit_cast_ptr handles the u8*→char* conversion directly. write(fl::u8 c) Delegates to write(char) via static_cast<char> instead of taking the address of c and pushing it through the void*+ bit_cast pipeline. write(char c) Unchanged. Net effect on each call site is a few bytes — exactly the order of magnitude the meta projected for Stage 5 (~0.5-1 KB). Validated by: - bash test fl_stl_string --cpp — passes (no behavioral change; both fl::u8 and char are the same physical byte, and bit_cast_ptr emits the same pointer that the prior bit_cast did). - bash lint --cpp — clean (initial reinterpret_cast attempt rejected by the project's ReinterpretCastChecker; bit_cast_ptr is the project-preferred form for this kind of pointer-type conversion). Refs #3122 B5, #2886 Stage 5.
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughTwo basic_string u8 write() simplification
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Poem
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
B5 of meta #3122, Stage 5 of #2886.
Three trivial delegates that previously each rebuilt a
const char*pointer via an unnecessarystatic_cast<const void*>→bit_cast_ptrchain (write(u8*)) or took the address of a single byte thenbit_cast'd it (write(u8)) are now simple one-line tail-calls:Net per-call-site savings: a few bytes — the order of magnitude the meta projected for Stage 5 (~0.5-1 KB across all call sites).
Validation
bash test fl_stl_string --cpp— passes.bash lint --cpp— clean.Initial
reinterpret_castattempt was rejected by the project'sReinterpretCastChecker;bit_cast_ptris the project-preferred form for this kind of pointer-type conversion.Refs #3122 B5, #2886 Stage 5.
Summary by CodeRabbit