More @safe pure nothrow @nogc in Reader.

This commit is contained in:
Ferdinand Majerech 2014-07-23 00:40:00 +02:00
parent 16b486c623
commit 48f86653dc

View file

@ -129,7 +129,7 @@ final class Reader
/// ///
/// Throws: ReaderException if trying to read past the end of the buffer /// Throws: ReaderException if trying to read past the end of the buffer
/// or if invalid data is read. /// or if invalid data is read.
dchar peek(size_t index = 0) @safe dchar peek(size_t index = 0) @safe pure const
{ {
if(buffer_.length <= bufferOffset_ + index) if(buffer_.length <= bufferOffset_ + index)
{ {
@ -147,7 +147,7 @@ final class Reader
/// Params: length = Number of characters to get. /// Params: length = Number of characters to get.
/// ///
/// Returns: Characters starting at current position or an empty slice if out of bounds. /// Returns: Characters starting at current position or an empty slice if out of bounds.
const(dstring) prefix(size_t length) @safe const(dstring) prefix(size_t length) @safe pure nothrow const @nogc
{ {
return slice(0, length); return slice(0, length);
} }
@ -161,7 +161,7 @@ final class Reader
/// end = End of the slice relative to current position. /// end = End of the slice relative to current position.
/// ///
/// Returns: Slice into the internal buffer or an empty slice if out of bounds. /// Returns: Slice into the internal buffer or an empty slice if out of bounds.
const(dstring) slice(size_t start, size_t end) @trusted const(dstring) slice(size_t start, size_t end) @trusted pure nothrow const @nogc
{ {
end += bufferOffset_; end += bufferOffset_;
start += bufferOffset_; start += bufferOffset_;
@ -176,7 +176,7 @@ final class Reader
/// ///
/// Throws: ReaderException if trying to read past the end of the buffer /// Throws: ReaderException if trying to read past the end of the buffer
/// or if invalid data is read. /// or if invalid data is read.
dchar get() @safe dchar get() @safe pure
{ {
const result = peek(); const result = peek();
forward(); forward();
@ -188,7 +188,7 @@ final class Reader
/// Params: length = Number or characters to get. /// Params: length = Number or characters to get.
/// ///
/// Returns: Characters starting at current position. /// Returns: Characters starting at current position.
dstring get(size_t length) @safe dstring get(size_t length) @safe pure nothrow
{ {
auto result = prefix(length).idup; auto result = prefix(length).idup;
forward(length); forward(length);
@ -198,7 +198,7 @@ final class Reader
/// Move current position forward. /// Move current position forward.
/// ///
/// Params: length = Number of characters to move position forward. /// Params: length = Number of characters to move position forward.
void forward(size_t length = 1) @safe void forward(size_t length = 1) @safe pure nothrow @nogc
{ {
mixin FastCharSearch!"\n\u0085\u2028\u2029"d search; mixin FastCharSearch!"\n\u0085\u2028\u2029"d search;