assumeSafeAppend in Loader functions to reduce GC usage.
This commit is contained in:
parent
a7f5aa1cf2
commit
4961cb163f
|
@ -224,10 +224,14 @@ struct Loader
|
||||||
/// Returns: Array of root nodes of all documents in the file/stream.
|
/// Returns: Array of root nodes of all documents in the file/stream.
|
||||||
///
|
///
|
||||||
/// Throws: YAMLException on a parsing error.
|
/// Throws: YAMLException on a parsing error.
|
||||||
Node[] loadAll() @safe
|
Node[] loadAll() @trusted
|
||||||
{
|
{
|
||||||
Node[] nodes;
|
Node[] nodes;
|
||||||
foreach(ref node; this) {nodes ~= node;}
|
foreach(ref node; this)
|
||||||
|
{
|
||||||
|
nodes.assumeSafeAppend();
|
||||||
|
nodes ~= node;
|
||||||
|
}
|
||||||
return nodes;
|
return nodes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -269,13 +273,14 @@ struct Loader
|
||||||
|
|
||||||
package:
|
package:
|
||||||
// Scan and return all tokens. Used for debugging.
|
// Scan and return all tokens. Used for debugging.
|
||||||
Token[] scan() @safe
|
Token[] scan() @trusted
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Token[] result;
|
Token[] result;
|
||||||
while(scanner_.checkToken())
|
while(scanner_.checkToken())
|
||||||
{
|
{
|
||||||
|
result.assumeSafeAppend();
|
||||||
result ~= scanner_.getToken();
|
result ~= scanner_.getToken();
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
|
Loading…
Reference in a new issue