"git@developer.sourcefind.cn:gaoqiong/composable_kernel.git" did not exist on "7cd48ef11e28a070488a7d865f31178184a6b335"
Commit 77c90a08 authored by Jesse Beder's avatar Jesse Beder
Browse files

Refactor plain scalar validation in the emitter to precompute the invalid regexes

parent bc86fd4a
......@@ -175,11 +175,17 @@ bool IsValidPlainScalar(const std::string& str, FlowType::value flowType,
}
// then check until something is disallowed
const RegEx& disallowed = (flowType == FlowType::Flow ? Exp::EndScalarInFlow()
: Exp::EndScalar()) ||
(Exp::BlankOrBreak() + Exp::Comment()) ||
Exp::NotPrintable() || Exp::Utf8_ByteOrderMark() ||
Exp::Break() || Exp::Tab();
static const RegEx& disallowed_flow =
Exp::EndScalarInFlow() || (Exp::BlankOrBreak() + Exp::Comment()) ||
Exp::NotPrintable() || Exp::Utf8_ByteOrderMark() || Exp::Break() ||
Exp::Tab();
static const RegEx& disallowed_block =
Exp::EndScalar() || (Exp::BlankOrBreak() + Exp::Comment()) ||
Exp::NotPrintable() || Exp::Utf8_ByteOrderMark() || Exp::Break() ||
Exp::Tab();
const RegEx& disallowed =
flowType == FlowType::Flow ? disallowed_flow : disallowed_block;
StringCharSource buffer(str.c_str(), str.size());
while (buffer) {
if (disallowed.Matches(buffer)) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment