diff options
| author | Dylan DPC <99973273+Dylan-DPC@users.noreply.github.com> | 2023-05-02 11:44:50 +0530 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-05-02 11:44:50 +0530 |
| commit | f916c44aecfc6c610f2d23cf929644aa08123547 (patch) | |
| tree | 2e56d694ce3e7681fbec27b21fadbdff9e880608 /compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp | |
| parent | 1cb63572d271855a5ccef79a3e10a8015d00f6ad (diff) | |
| parent | 76c99470244777da83fa4e1fef480d6d13af2a80 (diff) | |
| download | rust-f916c44aecfc6c610f2d23cf929644aa08123547.tar.gz rust-f916c44aecfc6c610f2d23cf929644aa08123547.zip | |
Rollup merge of #105076 - mina86:a, r=scottmcm
Refactor core::char::EscapeDefault and co. structures
Change core::char::{EscapeUnicode, EscapeDefault and EscapeDebug}
structures from using a state machine to computing escaped sequence
upfront and during iteration just going through the characters.
This is arguably simpler since it’s easier to think about having
a buffer and start..end range to iterate over rather than thinking
about a state machine.
This also harmonises implementation of aforementioned iterators and
core::ascii::EscapeDefault struct. This is done by introducing a new
helper EscapeIterInner struct which holds the buffer and offers simple
methods for iterating over range.
As a side effect, this probably optimises Display implementation for
those types since rather than calling write_char repeatedly, write_str
is invoked once. On 64-bit platforms, it also reduces size of some of
the structs:
| Struct | Before | After |
|----------------------------+--------+-------+
| core::char::EscapeUnicode | 16 | 12 |
| core::char::EscapeDefault | 16 | 12 |
| core::char::EscapeDebug | 16 | 16 |
My ulterior motive and reason why I started looking into this is
addition of as_str method to the iterators. With this change this
will became trivial. It’s also going to be trivial to implement
DoubleEndedIterator if that’s ever desired.
Diffstat (limited to 'compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp')
0 files changed, 0 insertions, 0 deletions
