about summary refs log tree commit diff
path: root/compiler/rustc_llvm/llvm-wrapper/CoverageMappingWrapper.cpp
diff options
context:
space:
mode:
authorMichal Nazarewicz <mina86@mina86.com>2022-11-29 21:02:11 +0100
committerMichal Nazarewicz <mina86@mina86.com>2023-04-05 19:09:55 +0200
commit45104397e5541b76e281ed9b72cb0a89a4c850eb (patch)
tree061d536123091249c38bad898087709dd7a13e8a /compiler/rustc_llvm/llvm-wrapper/CoverageMappingWrapper.cpp
parent4cb92cc83ac6b24d83f8a30763b276cadb8dc41d (diff)
downloadrust-45104397e5541b76e281ed9b72cb0a89a4c850eb.tar.gz
rust-45104397e5541b76e281ed9b72cb0a89a4c850eb.zip
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/CoverageMappingWrapper.cpp')
0 files changed, 0 insertions, 0 deletions