mirror of
https://github.com/dlang/dmd.git
synced 2025-04-27 21:51:03 +03:00
Change toString implementations to a common "get empty string" (#16185)
implementation, to avoid needless bloat. Change the literal toString to a static member, to allow calling at compile-time.
This commit is contained in:
parent
98443676dc
commit
bb6766a6ec
1 changed files with 12 additions and 10 deletions
|
@ -91,6 +91,14 @@
|
||||||
+/
|
+/
|
||||||
module core.interpolation;
|
module core.interpolation;
|
||||||
|
|
||||||
|
/++
|
||||||
|
Common implementation for returning an empty string, to avoid storing
|
||||||
|
multiple versions of the same function based on templated types below.
|
||||||
|
+/
|
||||||
|
public string __getEmptyString() @nogc pure nothrow @safe {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
/++
|
/++
|
||||||
Sentinel values to indicate the beginning and end of an
|
Sentinel values to indicate the beginning and end of an
|
||||||
interpolated expression sequence.
|
interpolated expression sequence.
|
||||||
|
@ -104,9 +112,7 @@ struct InterpolationHeader {
|
||||||
Returns `null` for easy compatibility with existing functions
|
Returns `null` for easy compatibility with existing functions
|
||||||
like `std.stdio.writeln` and `std.conv.text`.
|
like `std.stdio.writeln` and `std.conv.text`.
|
||||||
+/
|
+/
|
||||||
string toString() const @nogc pure nothrow @safe {
|
alias toString = __getEmptyString;
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// ditto
|
/// ditto
|
||||||
|
@ -115,9 +121,7 @@ struct InterpolationFooter {
|
||||||
Returns `null` for easy compatibility with existing functions
|
Returns `null` for easy compatibility with existing functions
|
||||||
like `std.stdio.writeln` and `std.conv.text`.
|
like `std.stdio.writeln` and `std.conv.text`.
|
||||||
+/
|
+/
|
||||||
string toString() const @nogc pure nothrow @safe {
|
alias toString = __getEmptyString;
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/++
|
/++
|
||||||
|
@ -130,7 +134,7 @@ struct InterpolatedLiteral(string text) {
|
||||||
segment of the tuple, for easy access and compatibility with
|
segment of the tuple, for easy access and compatibility with
|
||||||
existing functions like `std.stdio.writeln` and `std.conv.text`.
|
existing functions like `std.stdio.writeln` and `std.conv.text`.
|
||||||
+/
|
+/
|
||||||
string toString() const @nogc pure nothrow @safe {
|
static string toString() @nogc pure nothrow @safe {
|
||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -150,7 +154,5 @@ struct InterpolatedExpression(string text) {
|
||||||
Returns `null` for easy compatibility with existing functions
|
Returns `null` for easy compatibility with existing functions
|
||||||
like `std.stdio.writeln` and `std.conv.text`.
|
like `std.stdio.writeln` and `std.conv.text`.
|
||||||
+/
|
+/
|
||||||
string toString() const @nogc pure nothrow @safe {
|
alias toString = __getEmptyString;
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue