Author: Aaron Puchert Date: 2022-01-14T22:45:10+01:00 New Revision: bd0a970f5341f9981a9ad33fdfda99f8ff7348b3
URL: https://github.com/llvm/llvm-project/commit/bd0a970f5341f9981a9ad33fdfda99f8ff7348b3 DIFF: https://github.com/llvm/llvm-project/commit/bd0a970f5341f9981a9ad33fdfda99f8ff7348b3.diff LOG: Comment parsing: Simplify Lexer::skipLineStartingDecorations (NFC) Inspection of the first character can just be handled by the loop as well, it does exactly the same thing. Dereferencing the pointer a second time shouldn't be an issue: the middle end can eliminate that second read as it's separated from the first only by a pure function call. Reviewed By: gribozavr2 Differential Revision: https://reviews.llvm.org/D116186 Added: Modified: clang/lib/AST/CommentLexer.cpp Removed: ################################################################################ diff --git a/clang/lib/AST/CommentLexer.cpp b/clang/lib/AST/CommentLexer.cpp index 93531c06192d4..6e00c2aa7c280 100644 --- a/clang/lib/AST/CommentLexer.cpp +++ b/clang/lib/AST/CommentLexer.cpp @@ -94,31 +94,12 @@ void Lexer::skipLineStartingDecorations() { if (BufferPtr == CommentEnd) return; - switch (*BufferPtr) { - case ' ': - case '\t': - case '\f': - case '\v': { - const char *NewBufferPtr = BufferPtr; - NewBufferPtr++; - if (NewBufferPtr == CommentEnd) + const char *NewBufferPtr = BufferPtr; + while (isHorizontalWhitespace(*NewBufferPtr)) + if (++NewBufferPtr == CommentEnd) return; - - char C = *NewBufferPtr; - while (isHorizontalWhitespace(C)) { - NewBufferPtr++; - if (NewBufferPtr == CommentEnd) - return; - C = *NewBufferPtr; - } - if (C == '*') - BufferPtr = NewBufferPtr + 1; - break; - } - case '*': - BufferPtr++; - break; - } + if (*NewBufferPtr == '*') + BufferPtr = NewBufferPtr + 1; } namespace { _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits