Skip to content

Commit 5bfcfd0

Browse files
committed
Use inout in mir.format.print to reduce template bloat
1 parent f7c56dc commit 5bfcfd0

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

source/mir/format.d

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,7 @@ ref W printElement(C = char, EscapeFormat escapeFormat = EscapeFormat.ion, W, T)
489489
/++
490490
Multiargument overload.
491491
+/
492-
ref W print(C = char, W, Args...)(scope return ref W w, scope auto ref const Args args)
492+
ref W print(C = char, W, Args...)(scope return ref W w, scope auto ref const inout(Args) args)
493493
if (Args.length > 1)
494494
{
495495
foreach(i, ref c; args)
@@ -500,7 +500,7 @@ ref W print(C = char, W, Args...)(scope return ref W w, scope auto ref const Arg
500500
}
501501

502502
/// Prints enums
503-
ref W print(C = char, W, T)(scope return ref W w, const T c)
503+
ref W print(C = char, W, T)(scope return ref W w, const inout(T) c)
504504
if (is(T == enum))
505505
{
506506
import mir.enums: getEnumIndex, enumStrings;
@@ -566,7 +566,7 @@ version (mir_test) unittest
566566

567567
/// Prints associative array
568568
pragma(inline, false)
569-
ref W print(C = char, W, V, K)(scope return ref W w, scope const V[K] c)
569+
ref W print(C = char, W, V, K)(scope return ref W w, scope const inout(V)[inout(K)] c)
570570
{
571571
enum C left = '[';
572572
enum C right = ']';
@@ -600,7 +600,7 @@ version (mir_test) unittest
600600

601601
/// Prints array
602602
pragma(inline, false)
603-
ref W print(C = char, W, T)(scope return ref W w, scope const(T)[] c)
603+
ref W print(C = char, W, T)(scope return ref W w, scope const inout(T)[] c)
604604
if (!isSomeChar!T)
605605
{
606606
enum C left = '[';
@@ -686,15 +686,15 @@ version (mir_test) unittest
686686
}
687687

688688
/// Prints some string
689-
ref W print(C = char, W)(scope return ref W w, scope const(C)[] c)
689+
ref W print(C = char, W)(scope return ref W w, scope const inout(C)[] c)
690690
if (isSomeChar!C)
691691
{
692692
w.put(c);
693693
return w;
694694
}
695695

696696
/// Prints integers
697-
ref W print(C = char, W, I)(scope return ref W w, const I c)
697+
ref W print(C = char, W, I)(scope return ref W w, const inout(I) c)
698698
if (isIntegral!I && !is(I == enum))
699699
{
700700
static if (I.sizeof == 16)
@@ -714,7 +714,7 @@ ref W print(C = char, W, I)(scope return ref W w, const I c)
714714
}
715715

716716
/// Prints floating point numbers
717-
ref W print(C = char, W, T)(scope return ref W w, const T c, NumericSpec spec = NumericSpec.init)
717+
ref W print(C = char, W, T)(scope return ref W w, const inout(T) c, NumericSpec spec = NumericSpec.init)
718718
if(is(T == float) || is(T == double) || is(T == real))
719719
{
720720
import mir.bignum.decimal;
@@ -807,7 +807,7 @@ unittest
807807

808808
/// Prints structs and unions
809809
pragma(inline, false)
810-
ref W print(C = char, W, T)(scope return ref W w, ref const T c)
810+
ref W print(C = char, W, T)(scope return ref W w, ref const inout(T) c)
811811
if (is(T == struct) || is(T == union) && !is(T : NumericSpec))
812812
{
813813
static if (__traits(hasMember, T, "toString"))
@@ -870,7 +870,7 @@ ref W print(C = char, W, T)(scope return ref W w, ref const T c)
870870
/// ditto
871871
// FUTURE: remove it
872872
pragma(inline, false)
873-
ref W print(C = char, W, T)(scope return ref W w, scope const T c)
873+
ref W print(C = char, W, T)(scope return ref W w, scope const inout(T) c)
874874
if (is(T == struct) || is(T == union))
875875
{
876876
return print!(C, W, T)(w, c);
@@ -893,7 +893,7 @@ version (mir_test) unittest
893893

894894
/// Prints classes and interfaces
895895
pragma(inline, false)
896-
ref W print(C = char, W, T)(scope return ref W w, scope const T c)
896+
ref W print(C = char, W, T)(scope return ref W w, scope const inout(T) c)
897897
if (is(T == class) || is(T == interface))
898898
{
899899
enum C[4] Null = "null";

0 commit comments

Comments
 (0)