From 19f163a1503635529d3be751c503586bcca82c18 Mon Sep 17 00:00:00 2001 From: Ferdinand Majerech Date: Thu, 24 Jul 2014 23:17:24 +0200 Subject: [PATCH] Added a buffer to construct error messages in without allocation. --- source/dyaml/scanner.d | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/source/dyaml/scanner.d b/source/dyaml/scanner.d index 51eb54b..63645c5 100644 --- a/source/dyaml/scanner.d +++ b/source/dyaml/scanner.d @@ -157,6 +157,15 @@ final class Scanner /// Data for the exception to throw if error_ is true. ErrorData errorData_; + /// Error messages can be built in this buffer without using the GC. + /// + /// ScannerException (MarkedYAMLException) copies string data passed to its + /// constructor so it's safe to use slices of this buffer as parameters for + /// exceptions that may outlive the Scanner. The GC allocation when creating the + /// error message is removed, but the allocation when creating an exception is + /// not. + char[256] msgBuffer_; + public: ///Construct a Scanner using specified Reader. this(Reader reader) @safe nothrow