From d6300bc52e00da594b3c6c4aae3f47efdf915371 Mon Sep 17 00:00:00 2001 From: Cameron Ross Date: Tue, 15 Jan 2019 05:31:05 -0400 Subject: [PATCH] make Scanner a struct --- source/dyaml/loader.d | 2 +- source/dyaml/queue.d | 17 ++++++++++++++++- source/dyaml/scanner.d | 2 +- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/source/dyaml/loader.d b/source/dyaml/loader.d index 3ef8761..cd9c068 100644 --- a/source/dyaml/loader.d +++ b/source/dyaml/loader.d @@ -152,7 +152,7 @@ struct Loader try { reader_ = new Reader(yamlData); - scanner_ = new Scanner(reader_); + scanner_ = Scanner(reader_); parser_ = new Parser(scanner_); } catch(YAMLException e) diff --git a/source/dyaml/queue.d b/source/dyaml/queue.d index 3f090d0..710bd39 100644 --- a/source/dyaml/queue.d +++ b/source/dyaml/queue.d @@ -95,7 +95,22 @@ public: @disable bool opEquals(ref Queue); @disable int opCmp(ref Queue); - @disable this(this); + this(this) @safe nothrow @nogc + { + auto node = first_; + first_ = null; + last_ = null; + while (node !is null) + { + Node* newLast = makeNewNode(node.payload_); + if (last_ !is null) + last_.next_ = newLast; + if (first_ is null) + first_ = newLast; + last_ = newLast; + node = node.next_; + } + } ~this() @safe nothrow @nogc { diff --git a/source/dyaml/scanner.d b/source/dyaml/scanner.d index aa7cc0e..da13bc8 100644 --- a/source/dyaml/scanner.d +++ b/source/dyaml/scanner.d @@ -79,7 +79,7 @@ class ScannerException : MarkedYAMLException } /// Generates tokens from data provided by a Reader. -final class Scanner +struct Scanner { private: /// A simple key is a key that is not denoted by the '?' indicator.