outbuffer: add scope

This commit is contained in:
Walter Bright 2018-06-08 19:48:05 -07:00
parent 335a2a114f
commit 2c01a81b7a

View file

@ -41,7 +41,7 @@ class OutBuffer
/*********************************
* Convert to array of bytes.
*/
ubyte[] toBytes() { return data[0 .. offset]; }
inout(ubyte)[] toBytes() scope inout { return data[0 .. offset]; }
/***********************************
* Preallocate nbytes more to the size of the internal buffer.
@ -78,19 +78,19 @@ class OutBuffer
* Append data to the internal buffer.
*/
void write(const(ubyte)[] bytes)
void write(scope const(ubyte)[] bytes)
{
reserve(bytes.length);
data[offset .. offset + bytes.length] = bytes[];
offset += bytes.length;
}
void write(in wchar[] chars) @trusted
void write(scope const(wchar)[] chars) @trusted
{
write(cast(ubyte[]) chars);
}
void write(const(dchar)[] chars) @trusted
void write(scope const(dchar)[] chars) @trusted
{
write(cast(ubyte[]) chars);
}
@ -161,12 +161,12 @@ class OutBuffer
offset += real.sizeof;
}
void write(in char[] s) @trusted /// ditto
void write(scope const(char)[] s) @trusted /// ditto
{
write(cast(ubyte[]) s);
}
void write(OutBuffer buf) /// ditto
void write(scope const OutBuffer buf) /// ditto
{
write(buf.toBytes());
}
@ -245,7 +245,7 @@ class OutBuffer
* Append output of C's vprintf() to internal buffer.
*/
void vprintf(string format, va_list args) @trusted nothrow
void vprintf(scope string format, va_list args) @trusted nothrow
{
import core.stdc.stdio : vsnprintf;
import core.stdc.stdlib : alloca;
@ -290,7 +290,7 @@ class OutBuffer
* Append output of C's printf() to internal buffer.
*/
void printf(string format, ...) @trusted
void printf(scope string format, ...) @trusted
{
va_list ap;
va_start(ap, format);
@ -309,7 +309,7 @@ class OutBuffer
* $(REF _writef, std,stdio);
* $(REF formattedWrite, std,format);
*/
void writef(Char, A...)(in Char[] fmt, A args)
void writef(Char, A...)(scope const(Char)[] fmt, A args)
{
import std.format : formattedWrite;
formattedWrite(this, fmt, args);
@ -335,7 +335,7 @@ class OutBuffer
* $(REF _writefln, std,stdio);
* $(REF formattedWrite, std,format);
*/
void writefln(Char, A...)(in Char[] fmt, A args)
void writefln(Char, A...)(scope const(Char)[] fmt, A args)
{
import std.format : formattedWrite;
formattedWrite(this, fmt, args);