We have an old Radar about this, rdar://problem/16754935 <rdar://problem/16754935>. It's probably just a case we're missing in enum layout. My guess is that it's because we don't have a whole spare bit in a RawPointer, but we should be able to pick some up either from alignment or from ABI knowledge.
Jordan > On Aug 19, 2016, at 13:30, Ole Begemann via swift-dev <swift-dev@swift.org> > wrote: > > The Character type is essentially defined like this [1]: > > struct Character { > enum Representation { > // A _StringBuffer whose first grapheme cluster is self. > // NOTE: may be more than 1 Character long. > case large(_StringBuffer._Storage) > case small(Builtin.Int63) > } > > var _representation: Representation > } > > Note the type of the associated value for `case .small`, `Builtin.Int63`. > Presumably, this is so that the type fits into a single word, including the > single bit that is needed for the enum case. > > However, `MemoryLayout<Character>.size` returns 9. Given the above, I would > have expected 8 bytes. > > Why? Is this a potential optimization that hasn't been implemented? Or am I > missing something? > > Thanks > Ole > > [1]: > https://github.com/apple/swift/blob/master/stdlib/public/core/Character.swift > _______________________________________________ > swift-dev mailing list > swift-dev@swift.org > https://lists.swift.org/mailman/listinfo/swift-dev
_______________________________________________ swift-dev mailing list swift-dev@swift.org https://lists.swift.org/mailman/listinfo/swift-dev