Skip to content

Commit d9d6457

Browse files
authored
Merge pull request swiftlang#19652 from ranunez/patch-1
Update OptimizationTips.rst with consistent colon syntax
2 parents 4eafff2 + 3a52e8e commit d9d6457

File tree

1 file changed

+19
-19
lines changed

1 file changed

+19
-19
lines changed

Diff for: docs/OptimizationTips.rst

+19-19
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ in the following code snippet, ``a.aProperty``, ``a.doSomething()`` and
8282
dynamic doSomethingElse() { ... }
8383
}
8484

85-
class B : A {
85+
class B: A {
8686
override var aProperty {
8787
get { ... }
8888
set { ... }
@@ -155,7 +155,7 @@ assuming ``E``, ``F`` do not have any overriding declarations in the same file:
155155
}
156156

157157
class F {
158-
fileprivate var myPrivateVar : Int
158+
fileprivate var myPrivateVar: Int
159159
}
160160

161161
func usingE(_ e: E) {
@@ -193,11 +193,11 @@ Array.
193193

194194
// Don't use a class here.
195195
struct PhonebookEntry {
196-
var name : String
197-
var number : [Int]
196+
var name: String
197+
var number: [Int]
198198
}
199199

200-
var a : [PhonebookEntry]
200+
var a: [PhonebookEntry]
201201

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

278278
::
279279

280-
a : [Int]
281-
b : [Int]
282-
c : [Int]
280+
a: [Int]
281+
b: [Int]
282+
c: [Int]
283283

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

370370
protocol P {}
371-
struct Node : P {
372-
var left, right : P?
371+
struct Node: P {
372+
var left, right: P?
373373
}
374374

375375
struct Tree {
376-
var node : P?
376+
var node: P?
377377
init() { ... }
378378
}
379379

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

403403
::
404404

405-
struct Tree : P {
406-
var node : [P?]
405+
struct Tree: P {
406+
var node: [P?]
407407
init() {
408408
node = [thing]
409409
}
@@ -435,13 +435,13 @@ construct such a data structure:
435435
::
436436

437437
final class Ref<T> {
438-
var val : T
439-
init(_ v : T) {val = v}
438+
var val: T
439+
init(_ v: T) {val = v}
440440
}
441441

442442
struct Box<T> {
443-
var ref : Ref<T>
444-
init(_ x : T) { ref = Ref(x) }
443+
var ref: Ref<T>
444+
init(_ x: T) { ref = Ref(x) }
445445

446446
var value: T {
447447
get { return ref.val }
@@ -506,7 +506,7 @@ alive.
506506
withExtendedLifetime(Head) {
507507

508508
// Create an Unmanaged reference.
509-
var Ref : Unmanaged<Node> = Unmanaged.passUnretained(Head)
509+
var Ref: Unmanaged<Node> = Unmanaged.passUnretained(Head)
510510

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

541541
::
542542

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

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

0 commit comments

Comments
 (0)