let Scanner.handleDoubleQuotedScalarEscapes operate on const char arrays instead
This commit is contained in:
parent
bc7e7f9593
commit
bbfe2bbb69
|
@ -454,7 +454,7 @@ final class Parser
|
||||||
auto token = scanner_.front;
|
auto token = scanner_.front;
|
||||||
scanner_.popFront();
|
scanner_.popFront();
|
||||||
auto value = token.style == ScalarStyle.doubleQuoted
|
auto value = token.style == ScalarStyle.doubleQuoted
|
||||||
? handleDoubleQuotedScalarEscapes(token.value.dup)
|
? handleDoubleQuotedScalarEscapes(token.value)
|
||||||
: cast(string)token.value;
|
: cast(string)token.value;
|
||||||
|
|
||||||
implicit = (token.style == ScalarStyle.plain && tag is null) || tag == "!";
|
implicit = (token.style == ScalarStyle.plain && tag is null) || tag == "!";
|
||||||
|
@ -516,12 +516,12 @@ final class Parser
|
||||||
/// Handle escape sequences in a double quoted scalar.
|
/// Handle escape sequences in a double quoted scalar.
|
||||||
///
|
///
|
||||||
/// Moved here from scanner as it can't always be done in-place with slices.
|
/// Moved here from scanner as it can't always be done in-place with slices.
|
||||||
string handleDoubleQuotedScalarEscapes(char[] tokenValue) const @safe
|
string handleDoubleQuotedScalarEscapes(const(char)[] tokenValue) const @safe
|
||||||
{
|
{
|
||||||
string notInPlace;
|
string notInPlace;
|
||||||
bool inEscape;
|
bool inEscape;
|
||||||
auto appender = appender!(string)();
|
auto appender = appender!(string)();
|
||||||
for(char[] oldValue = tokenValue; !oldValue.empty();)
|
for(const(char)[] oldValue = tokenValue; !oldValue.empty();)
|
||||||
{
|
{
|
||||||
const dchar c = oldValue.front();
|
const dchar c = oldValue.front();
|
||||||
oldValue.popFront();
|
oldValue.popFront();
|
||||||
|
@ -571,7 +571,7 @@ final class Parser
|
||||||
|
|
||||||
const hexLength = dyaml.escapes.escapeHexLength(c);
|
const hexLength = dyaml.escapes.escapeHexLength(c);
|
||||||
// Any hex digits are 1-byte so this works.
|
// Any hex digits are 1-byte so this works.
|
||||||
char[] hex = oldValue[0 .. hexLength];
|
const(char)[] hex = oldValue[0 .. hexLength];
|
||||||
oldValue = oldValue[hexLength .. $];
|
oldValue = oldValue[hexLength .. $];
|
||||||
import std.ascii : isHexDigit;
|
import std.ascii : isHexDigit;
|
||||||
assert(!hex.canFind!(d => !d.isHexDigit),
|
assert(!hex.canFind!(d => !d.isHexDigit),
|
||||||
|
|
Loading…
Reference in a new issue