Skip to content

Commit e6d8d39

Browse files
committed
[Parse] Eliminate unnecessary type conversion wrapper function
1 parent d1ac870 commit e6d8d39

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

lib/Parse/Lexer.cpp

+2-8
Original file line numberDiff line numberDiff line change
@@ -91,12 +91,6 @@ static bool EncodeToUTF8(unsigned CharValue,
9191
return false;
9292
}
9393

94-
95-
/// CLO8 - Return the number of leading ones in the specified 8-bit value.
96-
static unsigned CLO8(unsigned char C) {
97-
return llvm::countl_one(uint32_t(C) << 24);
98-
}
99-
10094
/// isStartOfUTF8Character - Return true if this isn't a UTF8 continuation
10195
/// character, which will be of the form 0b10XXXXXX
10296
static bool isStartOfUTF8Character(unsigned char C) {
@@ -129,14 +123,14 @@ uint32_t swift::validateUTF8CharacterAndAdvance(const char *&Ptr,
129123

130124
// Read the number of high bits set, which indicates the number of bytes in
131125
// the character.
132-
unsigned EncodedBytes = CLO8(CurByte);
126+
unsigned char EncodedBytes = llvm::countl_one(CurByte);
133127
assert((EncodedBytes >= 2 && EncodedBytes <= 4));
134128

135129
// Drop the high bits indicating the # bytes of the result.
136130
unsigned CharValue = (unsigned char)(CurByte << EncodedBytes) >> EncodedBytes;
137131

138132
// Read and validate the continuation bytes.
139-
for (unsigned i = 1; i != EncodedBytes; ++i) {
133+
for (unsigned char i = 1; i != EncodedBytes; ++i) {
140134
if (Ptr >= End)
141135
return ~0U;
142136
CurByte = *Ptr;

0 commit comments

Comments
 (0)