Index: include/llvm/Support/YAMLTraits.h =================================================================== --- include/llvm/Support/YAMLTraits.h +++ include/llvm/Support/YAMLTraits.h @@ -471,11 +471,13 @@ if (S.equals(".inf") || S.equals(".Inf") || S.equals(".INF")) return true; - Regex FloatMatcher("^(\\.[0-9]+|[0-9]+(\\.[0-9]*)?)([eE][-+]?[0-9]+)?$"); - if (FloatMatcher.match(S)) - return true; + // Don't waste time regex matching on anything obviously non-numeric. + static const char FloatChars[] = "+-0123456789.eE"; + if (S.find_first_not_of(FloatChars) != StringRef::npos) + return false; - return false; + Regex FloatMatcher("^(\\.[0-9]+|[0-9]+(\\.[0-9]*)?)([eE][-+]?[0-9]+)?$"); + return FloatMatcher.match(S); } inline bool isNumeric(StringRef S) {