Skip to content

Hot path for ascii output #1151

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: next
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/utf8.c
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ int TY_(DecodeUTF8BytesToChar)( uint* c, uint firstByte, ctmbstr successorBytes,
return 0;
}

int TY_(EncodeCharToUTF8Bytes)( uint c, tmbstr encodebuf,
int TY_(EncodeCharToUTF8BytesSlow)( uint c, tmbstr encodebuf,
TidyOutputSink* outp, int* count )
{
byte tempbuf[10] = {0};
Expand Down
15 changes: 14 additions & 1 deletion src/utf8.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,22 @@
TY_PRIVATE int TY_(DecodeUTF8BytesToChar)( uint* c, uint firstByte, ctmbstr successorBytes,
TidyInputSource* inp, int* count );

TY_PRIVATE int TY_(EncodeCharToUTF8Bytes)( uint c, tmbstr encodebuf,
TY_PRIVATE int TY_(EncodeCharToUTF8BytesSlow)( uint c, tmbstr encodebuf,
TidyOutputSink* outp, int* count );

static inline int TY_(EncodeCharToUTF8Bytes)(uint c, tmbstr encodebuf,
TidyOutputSink *outp, int *count) {
if (c <= 0x7F) {
if (encodebuf)
encodebuf[0] = c;
if (outp)
outp->putByte(outp->sinkData, c);
*count = 1;
return 0;
}

TY_(EncodeCharToUTF8BytesSlow)(c, encodebuf, outp, count);
}

TY_PRIVATE uint TY_(GetUTF8)( ctmbstr str, uint *ch );
TY_PRIVATE tmbstr TY_(PutUTF8)( tmbstr buf, uint c );
Expand Down