This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// A few demonstrations of the copy-on-write behaviour of containers in the Swift Standard Library. | |
/// https://jaredkhan.com/blog/swift-copy-on-write | |
/// Pause execution so that we can look at memory usage in Activity Monitor or similar. | |
func pause(expectedMemoryUsage: Int) { | |
print("Expecting memory usage of about \(expectedMemoryUsage)MB. Press [enter] to continue") | |
let _ = readLine() | |
} | |
/// Demonstrate the copy-on-write behaviour of a large array. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct ImageHero: Nodeable { | |
let background: BackgroundType | |
let imagePath: String | |
let alternateText: String | |
var node: Node { | |
return El.Div[ | |
Attr.className => "ImageHero", | |
Attr.style => background.style | |
].containing( |