Skip to content

Commit 2607264

Browse files
committed
Allocate visitor on the stack
1 parent 82bdc1e commit 2607264

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

ddoc/source/assert_writeln_magic.d

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -196,10 +196,9 @@ private auto assertWritelnModuleImpl(string fileText)
196196
{
197197
import std.string : representation;
198198
auto fl = FileLines(fileText);
199-
auto visitor = new TestVisitor!(typeof(fl))(fl);
199+
scope visitor = new TestVisitor!(typeof(fl))(fl);
200200
// libdparse doesn't allow to work on immutable source code
201201
parseString(cast(ubyte[]) fileText.representation, visitor);
202-
delete visitor;
203202
return fl;
204203
}
205204

@@ -274,9 +273,8 @@ version(unittest)
274273
{
275274
import std.string : representation;
276275
auto mock = FileLinesMock(sourceCode.split("\n"));
277-
auto visitor = new TestVisitor!(typeof(mock))(mock);
276+
scope visitor = new TestVisitor!(typeof(mock))(mock);
278277
parseString(sourceCode.representation.dup, visitor);
279-
delete visitor;
280278
return mock;
281279
}
282280
}

0 commit comments

Comments
 (0)