<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Fri, Oct 18, 2013 at 8:35 PM, Rafael Espíndola <span dir="ltr"><<a href="mailto:rafael.espindola@gmail.com" target="_blank" class="cremed">rafael.espindola@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">> Currently decl chaining is O(n). We use a circular singly linked list<br>
> that points to the previous element and has a bool to say if we are<br>
> the first element (and actually point to the last).<br>
><br>
> Adding a new decl is O(n) because we have to find the first element by<br>
> walking the prev links. One way to make this O(1) that is sure to work<br>
> is a doubly linked list, but that would be very wasteful in memory.<br></div></blockquote><div><br></div><div>What about just storing both the first and the last and keeping the direction as it is now?</div><div> </div>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">
><br>
> What this patch does is reverse the list so that a decl points to the<br>
> next decl (or to the first if it is the last). With this chaining<br>
> becomes O(1). The flip side is that getPreviousDecl is now O(n).<br>
<br>
</div>The patch still needs work, but I managed to convert all calls to<br>
getPreviousDecl in the above testcase. In my machine the clang -cc1<br>
time on it goes from  4.819s to 0.865s now (5.57x faster).<br>
<br>
<br>
Cheers,<br>
Rafael<br>
<br>_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@cs.uiuc.edu" class="cremed">cfe-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank" class="cremed">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
<br></blockquote></div><br></div></div>