Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Size, stride, and alignment of two structs
struct CertifiedPuppy1 {
let age: Int
let isTrained: Bool
let isCertified: Bool
}
MemoryLayout<CertifiedPuppy1>.size // 10
MemoryLayout<CertifiedPuppy1>.stride // 16
MemoryLayout<CertifiedPuppy1>.alignment // 8
struct CertifiedPuppy2 {
let isTrained: Bool
let age: Int
let isCertified: Bool
}
MemoryLayout<CertifiedPuppy2>.size // 17
MemoryLayout<CertifiedPuppy2>.stride // 24
MemoryLayout<CertifiedPuppy2>.alignment // 8
@MrNickBarker

This comment has been minimized.

Copy link

MrNickBarker commented Mar 16, 2018

Will the compiler ever optimize CertifiedPuppy2?

@mrcompoteee

This comment has been minimized.

Copy link

mrcompoteee commented Feb 25, 2019

Will the CertifiedPuppy2 be optimized?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.