<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Tue, Nov 19, 2013 at 9:02 AM, Shankar Kalpathi Easwaran <span dir="ltr"><<a href="mailto:shankarke@gmail.com" target="_blank">shankarke@gmail.com</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
<br>
================ </blockquote><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Comment at: lib/ReaderWriter/Native/WriterNative.cpp:175-185<br>
@@ +174,13 @@<br>
+  // possible.<br>
+  void maybeConvertReferencesToV1() {<br>
+    std::set<int64_t> addends;<br>
+    for (const NativeReferenceIvarsV2 &ref : _referencesV2) {<br>
+      if (!canConvertReferenceToV1(ref))<br>
+        return;<br>
+      addends.insert(ref.addend);<br>
+      if (addends.size() >= UINT16_MAX)<br>
+        return;<br>
+    }<br>
+    convertReferencesToV1();<br>
+  }<br>
+<br>
----------------<br>
This converts either all references to V1 or everything remains V2. We might want to convert a part of the references if the targetIndex < UINT16_MAX and leave the rest to V2, if the targetIndex is higher than 16 bits.<br>

</blockquote><div><br></div><div>It feels that it's overly complicated to emit a mixed file of V1 and V2. It's going to be slower too because we need to look at the index of a reference to decide the reference is in V1 or V2.</div>

<div><br></div><div>Let's calculate the size increase when V2 is used instead of V1. sizeof(V1) is 8. sizeof(V2) is 24. So, by converting 65535 V1 references to V2, the file grows 1MB. Actual increase would be smaller than that because V2 would get rid of the AddendTable. A file containing so much references is large anyway, I don't think less than 1MB increase would matter a lot for such file. Thus I'd think simplicity wins here.</div>

<div><br></div><div>The native format is not really being used by anyone, so we don't know what is going to be an issue and what's not going to be. Implementing something to "optimize" Native format in such a way to increase the complexity of code would be a premature optimization at this moment, I think.</div>

</div></div></div>