Use StringRef::drop_while() to simplify a while loop
authorLei Zhang <antiagainst@google.com>
Sat, 20 Apr 2019 11:05:38 +0000 (04:05 -0700)
committerMehdi Amini <joker.eph@gmail.com>
Wed, 24 Apr 2019 05:01:35 +0000 (22:01 -0700)
--

PiperOrigin-RevId: 244488612

mlir/lib/IR/AsmPrinter.cpp

index 02550b3..ce4311d 100644 (file)
@@ -710,12 +710,10 @@ static bool isDialectTypeSimpleEnoughForPrettyForm(StringRef typeName) {
 
   // Ignore all the characters that are valid in an identifier in the type
   // name.
-  while (isalpha(typeName.front()) || isdigit(typeName.front()) ||
-         typeName.front() == '.') {
-    typeName = typeName.drop_front();
-    if (typeName.empty())
-      return true;
-  }
+  typeName =
+      typeName.drop_while([](char c) { return llvm::isAlnum(c) || c == '.'; });
+  if (typeName.empty())
+    return true;
 
   // If we got to an unexpected character, then it must be a <>.  Check those
   // recursively.