<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, Feb 4, 2014 at 11:32 AM, Nick Kledzik <span dir="ltr"><<a href="mailto:kledzik@apple.com" target="_blank">kledzik@apple.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div class="im"><br><div><div>On Feb 1, 2014, at 9:41 AM, Eli Bendersky <<a href="mailto:eliben@google.com" target="_blank">eliben@google.com</a>> wrote:</div>
<blockquote type="cite"><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">
It strikes me as strange to add a dependency for Allocator on StringRef for this case (and I guess on ArrayRef too). If this is a service StringRef needs from Allocator and not vice versa, wouldn't it make more sense to add this utility method to StringRef (taking an Allocator)?</div>
</blockquote><br></div></div><div>Ok, I’ve inverted the layering with this patch. Allocator.h goes back to what it was and I’ve added a copy(BumpPtrAllocator &) method to StringRef and ArrayRef<>. And the test cases move out of the allocator and into StringRef and ArrayRef.</div>
<div><br></div><div></div></div><br><div style="word-wrap:break-word"><div></div><div><br></div></div></blockquote><div><br></div><div>Great. Thanks, Nick.</div><div><br></div><div>Eli</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div style="word-wrap:break-word"><div></div><div>The motivation for these utilities is that BumpPtrAllocator has a one line syntax for allocating and initializing a new *object* in the bump pointer pool:</div><div><br></div>
<div> Foo *myFoo = (myAllocator) Foo(args);</div><div><br></div><div>But if you want to copy a string in to the bump pointer pool and get a StringRef to it, it is multiple steps. With this patch, it is now just:</div>
<div><br></div><div> StringRef myCopy = myStr.copy(myAllocator);</div><div><br></div><div>-Nick</div><div><br></div></div>
<br></blockquote></div><br></div></div>