Reader buffer is again dchar[].

This commit is contained in:
Ferdinand Majerech 2014-07-24 02:40:32 +02:00
parent 36e7954756
commit e493e7299d

View file

@ -66,7 +66,7 @@ final class Reader
{
private:
// Buffer of currently loaded characters.
dstring buffer_ = null;
dchar[] buffer_ = null;
// Current position within buffer. Only data after this position can be read.
uint bufferOffset_ = 0;
// Index of the current character in the buffer.
@ -115,7 +115,7 @@ final class Reader
throw new ReaderException("UTF decoding error: " ~ msg);
}
buffer_ = cast(dstring)decodeResult.decoded;
buffer_ = decodeResult.decoded;
// The part of buffer_ excluding trailing zeroes.
auto noZeros = buffer_;
while(!noZeros.empty && noZeros.back == '\0') { noZeros.popBack(); }
@ -171,12 +171,12 @@ final class Reader
/// slice will be shorter.
///
/// Returns: Slice into the internal buffer or an empty slice if out of bounds.
dstring slice(size_t start, size_t end) @safe pure nothrow const @nogc
dstring slice(size_t start, size_t end) @trusted pure nothrow const @nogc
{
start += bufferOffset_;
end = min(buffer_.length, end + bufferOffset_);
return end > start ? buffer_[start .. end] : "";
return end > start ? cast(dstring)buffer_[start .. end] : "";
}
/// Get the next character, moving buffer position beyond it.