Skip to content

Update OptimizationTips.rst with consistent colon syntax #19652

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 18, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 19 additions & 19 deletions docs/OptimizationTips.rst
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ in the following code snippet, ``a.aProperty``, ``a.doSomething()`` and
dynamic doSomethingElse() { ... }
}

class B : A {
class B: A {
override var aProperty {
get { ... }
set { ... }
Expand Down Expand Up @@ -155,7 +155,7 @@ assuming ``E``, ``F`` do not have any overriding declarations in the same file:
}

class F {
fileprivate var myPrivateVar : Int
fileprivate var myPrivateVar: Int
}

func usingE(_ e: E) {
Expand Down Expand Up @@ -193,11 +193,11 @@ Array.

// Don't use a class here.
struct PhonebookEntry {
var name : String
var number : [Int]
var name: String
var number: [Int]
}

var a : [PhonebookEntry]
var a: [PhonebookEntry]

Keep in mind that there is a trade-off between using large value types and using
reference types. In certain cases, the overhead of copying and moving around
Expand Down Expand Up @@ -277,9 +277,9 @@ safe.

::

a : [Int]
b : [Int]
c : [Int]
a: [Int]
b: [Int]
c: [Int]

// Precondition: for all a[i], b[i]: a[i] + b[i] does not overflow!
for i in 0 ... n {
Expand Down Expand Up @@ -368,12 +368,12 @@ represented as values, so this example is somewhat realistic.
::

protocol P {}
struct Node : P {
var left, right : P?
struct Node: P {
var left, right: P?
}

struct Tree {
var node : P?
var node: P?
init() { ... }
}

Expand Down Expand Up @@ -402,8 +402,8 @@ argument drops from being O(n), depending on the size of the tree to O(1).

::

struct Tree : P {
var node : [P?]
struct Tree: P {
var node: [P?]
init() {
node = [thing]
}
Expand Down Expand Up @@ -435,13 +435,13 @@ construct such a data structure:
::

final class Ref<T> {
var val : T
init(_ v : T) {val = v}
var val: T
init(_ v: T) {val = v}
}

struct Box<T> {
var ref : Ref<T>
init(_ x : T) { ref = Ref(x) }
var ref: Ref<T>
init(_ x: T) { ref = Ref(x) }

var value: T {
get { return ref.val }
Expand Down Expand Up @@ -506,7 +506,7 @@ alive.
withExtendedLifetime(Head) {

// Create an Unmanaged reference.
var Ref : Unmanaged<Node> = Unmanaged.passUnretained(Head)
var Ref: Unmanaged<Node> = Unmanaged.passUnretained(Head)

// Use the unmanaged reference in a call/variable access. The use of
// _withUnsafeGuaranteedRef allows the compiler to remove the ultimate
Expand Down Expand Up @@ -540,7 +540,7 @@ protocols as class-only protocols to get better runtime performance.

::

protocol Pingable : AnyObject { func ping() -> Int }
protocol Pingable: AnyObject { func ping() -> Int }

.. https://developer.apple.com/library/ios/documentation/Swift/Conceptual/Swift_Programming_Language/Protocols.html

Expand Down