<div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Oct 11, 2014 at 4:51 PM, Philip Reames <span dir="ltr"><<a href="mailto:listmail@philipreames.com" target="_blank">listmail@philipreames.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div id=":jjs" class="a3s" style="overflow:hidden">Ben,<br>
<br>
Could you give a bit of context on this change for those of us unfamiliar with the issue? I don't understand why the new code is advantageous.<span class=""><br>
<br>
On 10/11/2014 12:13 PM, Benjamin Kramer wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
- CachedAssumeCalls.erase(F);<br>
+ auto I = CachedAssumeCalls.find_as(F);<br>
+ if (I != CachedAssumeCalls.end())<br>
+ CachedAssumeCalls.erase(I);<br>
}<br>
</blockquote></span>
This particular part seems ugly. What's the semantic difference here? Why is this better? If it's better, why isn't it simply part of the standard erase routine?</div></blockquote></div><br>Er, I think the commit log gave you the key point: this avoids creating a temporary CallbackVH. If you want to understand why, look at the signatures for erase, find_as, and find? The trick of 'find_as' is to let you not construct a same-type object for the lookup, but instead some other type that can be used in the lookup can be passed. Primarily used with string and stringref types for example.</div><div class="gmail_extra"><br></div><div class="gmail_extra">The problem with creating CallbackVH's should be clear from its documentation: every instance has to be inserted into the use list on construction and removed on destruction. This churn to the use lists dirties lots of cache lines and has other rather unfortunate costs.</div></div>