From fe87dc7c4216f7f695ccf3500f92af0cece3d60b Mon Sep 17 00:00:00 2001 From: Vladimir Panteleev Date: Sun, 1 Sep 2019 03:21:26 +0000 Subject: [PATCH] Fix Issue 20186 - File size of "Hello, world" executable increased by 185KB We can delay the std.format import until the relevant templates are instantiated. --- std/array.d | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/std/array.d b/std/array.d index 008c1f11c..c04d6bb59 100644 --- a/std/array.d +++ b/std/array.d @@ -3216,7 +3216,6 @@ struct Appender(A) if (isDynamicArray!A) { import core.memory : GC; - import std.format : FormatSpec; private alias T = ElementEncodingType!A; @@ -3559,7 +3558,7 @@ if (isDynamicArray!A) * Returns: * A `string` if `writer` is not set; `void` otherwise. */ - string toString() const + string toString()() const { import std.format : singleSpec; @@ -3582,15 +3581,20 @@ if (isDynamicArray!A) } /// ditto - void toString(Writer)(ref Writer w, scope const ref FormatSpec!char fmt) const + template toString(Writer) if (isOutputRange!(Writer, char)) { - import std.format : formatValue; - import std.range.primitives : put; - put(w, Unqual!(typeof(this)).stringof); - put(w, '('); - formatValue(w, data, fmt); - put(w, ')'); + import std.format : FormatSpec; + + void toString(ref Writer w, scope const ref std.format.FormatSpec!char fmt) const + { + import std.format : formatValue; + import std.range.primitives : put; + put(w, Unqual!(typeof(this)).stringof); + put(w, '('); + formatValue(w, data, fmt); + put(w, ')'); + } } // @@@DEPRECATED_2.089@@@