aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/AST/CommentLexer.cpp
diff options
context:
space:
mode:
authorAaron Puchert <aaron.puchert@sap.com>2022-01-14 22:44:58 +0100
committerAaron Puchert <aaron.puchert@sap.com>2022-01-14 22:45:10 +0100
commitbd0a970f5341f9981a9ad33fdfda99f8ff7348b3 (patch)
tree1a5b79a28438783b5e53f70aa38c019cb219d638 /clang/lib/AST/CommentLexer.cpp
parent0b442db9f62e85af1968f0df1087ee9de1d43d9a (diff)
downloadllvm-bd0a970f5341f9981a9ad33fdfda99f8ff7348b3.zip
llvm-bd0a970f5341f9981a9ad33fdfda99f8ff7348b3.tar.gz
llvm-bd0a970f5341f9981a9ad33fdfda99f8ff7348b3.tar.bz2
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
Diffstat (limited to 'clang/lib/AST/CommentLexer.cpp')
-rw-r--r--clang/lib/AST/CommentLexer.cpp29
1 files changed, 5 insertions, 24 deletions
diff --git a/clang/lib/AST/CommentLexer.cpp b/clang/lib/AST/CommentLexer.cpp
index 93531c0..6e00c2a 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 {