<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div><blockquote type="cite" class=""><div class="">On Nov 6, 2017, at 3:46 AM, Kelvin Ma via swift-dev &lt;<a href="mailto:swift-dev@swift.org" class="">swift-dev@swift.org</a>&gt; wrote:</div><div class=""><div dir="ltr" class=""><div class="">i noticed that this enum takes up 9 bytes of storage <br class=""><span style="font-family:monospace,monospace" class=""><br class="">&nbsp; 1&gt; enum QuantizationTable&nbsp; <br class="">&nbsp; 2. { <br class="">&nbsp; 3.&nbsp;&nbsp;&nbsp;&nbsp; case q8 (UnsafeMutablePointer&lt;UInt8&gt;),&nbsp; <br class="">&nbsp; 4.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; q16(UnsafeMutablePointer&lt;UInt16&gt;)&nbsp; <br class="">&nbsp; 5. } <br class="">&nbsp; 6&gt; MemoryLayout&lt;QuantizationTable&gt;.size<br class="">$R0: Int = 9</span><br class=""><br class=""></div>but when i make it optional, it takes up 10<br class=""><div class=""><br class=""><span style="font-family:monospace,monospace" class="">&nbsp; 7&gt; MemoryLayout&lt;QuantizationTable?&gt;.size <br class="">$R1: Int = 10<br class=""></span><br class=""></div><div class="">can’t the compiler just tack the <span style="font-family:monospace,monospace" class="">nil</span> case onto the original enum as a third case? after all, this works fine <br class=""></div><div class=""><br class=""></div><div class=""><span style="font-family:monospace,monospace" class="">&nbsp; 1&gt; enum QuantizationTable&nbsp; <br class="">&nbsp; 2. { <br class="">&nbsp; 3.&nbsp;&nbsp;&nbsp;&nbsp; case q8 (UnsafeMutablePointer&lt;UInt8&gt;),&nbsp; <br class="">&nbsp; 4.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; q16(UnsafeMutablePointer&lt;UInt16&gt;),&nbsp; <br class="">&nbsp; 5.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; none <br class="">&nbsp; 6. } <br class="">&nbsp; 7&gt; MemoryLayout&lt;QuantizationTable&gt;.size<br class="">$R0: Int = 9</span><br class=""></div><div class=""><br class=""></div><div class="">the way i’m using it atm it all gets padded to 16 anyway so i don’t care that much but is this something that’s being looked at?<br class=""></div></div></div></blockquote><div><br class=""></div></div>We could, yes. &nbsp;Our experience with enum layout optimization is that it's one of those things that doesn't seem to bottom out: you can always keep improving it in one way or another.<div class=""><br class=""></div><div class="">It is an important goal of our ABI stability plan that future versions of Swift will be able to improve layouts for types that aren't required to interoperate with older versions, crucially including the private and internal types in a module.<br class=""><div class=""><br class=""></div><div class="">John.</div></div></body></html>