mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Do not link (import from stdlib) the 'print' family of functions.
We don't need the "print to stdout" family of functions to be fast and prefer to reduce the binary size by not linking the printing code (and all of its dependencies). This reduces the SIL of the code of a file that contains 'println()' from ~4000** lines of SIL down to ~200. **(depending on the assert configuration) Swift SVN r24404
This commit is contained in:
@@ -102,6 +102,7 @@ func _adHocPrint<T, TargetStream : OutputStreamType>(
|
||||
/// Do not overload this function for your type. Instead, adopt one of the
|
||||
/// protocols mentioned above.
|
||||
@inline(never)
|
||||
@semantics("stdlib.noimport")
|
||||
public func print<T, TargetStream : OutputStreamType>(
|
||||
object: T, inout target: TargetStream
|
||||
) {
|
||||
@@ -133,6 +134,7 @@ public func print<T, TargetStream : OutputStreamType>(
|
||||
/// Do not overload this function for your type. Instead, adopt one of the
|
||||
/// protocols mentioned above.
|
||||
@inline(never)
|
||||
@semantics("stdlib.noimport")
|
||||
public func println<T, TargetStream : OutputStreamType>(
|
||||
object: T, inout target: TargetStream
|
||||
) {
|
||||
@@ -148,6 +150,8 @@ public func println<T, TargetStream : OutputStreamType>(
|
||||
///
|
||||
/// Do not overload this function for your type. Instead, adopt one of the
|
||||
/// protocols mentioned above.
|
||||
@inline(never)
|
||||
@semantics("stdlib.noimport")
|
||||
public func print<T>(object: T) {
|
||||
var stdoutStream = _Stdout()
|
||||
print(object, &stdoutStream)
|
||||
@@ -163,6 +167,7 @@ public func print<T>(object: T) {
|
||||
/// Do not overload this function for your type. Instead, adopt one of the
|
||||
/// protocols mentioned above.
|
||||
@inline(never)
|
||||
@semantics("stdlib.noimport")
|
||||
public func println<T>(object: T) {
|
||||
var stdoutStream = _Stdout()
|
||||
print(object, &stdoutStream)
|
||||
@@ -171,6 +176,7 @@ public func println<T>(object: T) {
|
||||
|
||||
/// Writes a single newline character into the standard output.
|
||||
@inline(never)
|
||||
@semantics("stdlib.noimport")
|
||||
public func println() {
|
||||
var stdoutStream = _Stdout()
|
||||
stdoutStream.write("\n")
|
||||
|
||||
Reference in New Issue
Block a user