Skip to content

Commit cde46dc

Browse files
committed
Use isspace instead of ' '
1 parent 5d2a8a3 commit cde46dc

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

llvm/lib/Frontend/OpenMP/DirectiveNameParser.cpp

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include "llvm/Frontend/OpenMP/OMP.h"
1313

1414
#include <cassert>
15+
#include <cctype>
1516
#include <memory>
1617

1718
namespace llvm::omp {
@@ -40,23 +41,24 @@ DirectiveNameParser::consume(const State *Current, StringRef Tok) const {
4041
SmallVector<StringRef> DirectiveNameParser::tokenize(StringRef Str) {
4142
SmallVector<StringRef> Tokens;
4243

43-
auto nextChar = [](StringRef N, size_t I) {
44-
while (I < N.size() && N[I] == ' ')
44+
auto NextChar = [](StringRef N, size_t I) {
45+
while (I < N.size() && isspace(N[I]))
4546
++I;
4647
return I;
4748
};
48-
auto nextSpace = [](StringRef N, size_t I) {
49-
size_t S = N.find(' ', I);
50-
return S != StringRef::npos ? S : N.size();
49+
auto NextSpace = [](StringRef N, size_t I) {
50+
while (I < N.size() && !isspace(N[I]))
51+
++I;
52+
return I;
5153
};
5254

53-
size_t From = nextChar(Str, 0);
55+
size_t From = NextChar(Str, 0);
5456
size_t To = 0;
5557

5658
while (From != Str.size()) {
57-
To = nextSpace(Str, From);
59+
To = NextSpace(Str, From);
5860
Tokens.push_back(Str.substr(From, To - From));
59-
From = nextChar(Str, To);
61+
From = NextChar(Str, To);
6062
}
6163

6264
return Tokens;

0 commit comments

Comments
 (0)