[FormattedStream] Add ASCII fast path (#117892)
Printing IR spends a large amount of time updating the column count via generic UTF-8 APIs. Speed it up by adding a fast path for the common printable ASCII case. This makes `-print-on-crash -print-module-scope` about two times faster.
This commit is contained in:
parent
ccc471fe3e
commit
da23a8372c
@ -75,6 +75,13 @@ void formatted_raw_ostream::UpdatePosition(const char *Ptr, size_t Size) {
|
||||
// Now scan the rest of the buffer.
|
||||
unsigned NumBytes;
|
||||
for (const char *End = Ptr + Size; Ptr < End; Ptr += NumBytes) {
|
||||
// Fast path for printable ASCII characters without special handling.
|
||||
if (*Ptr >= 0x20 && *Ptr <= 0x7e) {
|
||||
NumBytes = 1;
|
||||
++Column;
|
||||
continue;
|
||||
}
|
||||
|
||||
NumBytes = getNumBytesForUTF8(*Ptr);
|
||||
|
||||
// The buffer might end part way through a UTF-8 code unit sequence for a
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user