From 75ed314dd66ba5460413a5d8c5324e37dbc6fb31 Mon Sep 17 00:00:00 2001 From: Ferdinand Majerech Date: Tue, 5 Aug 2014 01:51:32 +0200 Subject: [PATCH] More FastCharSearch. --- source/dyaml/scanner.d | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/source/dyaml/scanner.d b/source/dyaml/scanner.d index f04a8c9..eb4bd22 100644 --- a/source/dyaml/scanner.d +++ b/source/dyaml/scanner.d @@ -798,9 +798,15 @@ final class Scanner bool checkPlain() @safe pure nothrow @nogc { const c = reader_.peek(); - return !("-?:,[]{}#&*!|>\'\"%@` \t\0\n\r\u0085\u2028\u2029"d.canFind(c)) || - (!" \t\0\n\r\u0085\u2028\u2029"d.canFind(reader_.peek(1)) && - (c == '-' || (flowLevel_ == 0 && "?:"d.canFind(c)))); + mixin FastCharSearch!"-?:,[]{}#&*!|>\'\"%@` \t\0\n\r\u0085\u2028\u2029"d + searchPlainNotFirstChar; + if(!searchPlainNotFirstChar.canFind(c)) + { + return true; + } + mixin FastCharSearch!" \t\0\n\r\u0085\u2028\u2029"d searchAllWhitespace; + return !searchAllWhitespace.canFind(reader_.peek(1)) && + (c == '-' || (flowLevel_ == 0 && (c == '?' || c == ':'))); } /// Move to the next non-space character.