<div dir="ltr">I tried a few different ideas. First, I tried to pass an InputFile to check() as you suggested, but that ended up having four functions, which looked ugly<div><br></div><div><div>  template <class T> T check(ErrorOr<T> E, const Twine &Prefix);</div><div>  template <class T> T check(Expected<T> E, const Twine &Prefix);</div></div><div><div><div>  template <class T> T check(ErrorOr<T> E, InputFile *File);</div><div>  template <class T> T check(Expected<T> E, InputFile *File);</div></div></div><div><br></div><div>Next I tried to make toString() cheaper by making it return a Twine instead of a StringRef, but that didn't work because sometimes toString(Symbol) needs to create a new string to demangle a symbol.</div><div><br></div><div>So looks like there's no good way to remove that member variable.</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Mar 30, 2017 at 2:49 PM, Rafael Espíndola <span dir="ltr"><<a href="mailto:rafael.espindola@gmail.com" target="_blank">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">I see. Maybe pass InputFile to check and have check call getLogName()<br>
only when needed?<br>
<br>
Cheers,<br>
Rafael<br>
<div class="HOEnZb"><div class="h5"><br>
<br>
On 30 March 2017 at 17:46, Rui Ueyama <<a href="mailto:ruiu@google.com">ruiu@google.com</a>> wrote:<br>
> We may be able to do that. I had a concern about the performance penalty<br>
> because that function would be called on every check() invocation, though.<br>
><br>
> On Thu, Mar 30, 2017 at 2:43 PM, Rafael Espíndola<br>
> <<a href="mailto:rafael.espindola@gmail.com">rafael.espindola@gmail.com</a>> wrote:<br>
>><br>
>> On 30 March 2017 at 17:32, Rui Ueyama <<a href="mailto:ruiu@google.com">ruiu@google.com</a>> wrote:<br>
>> > We use a different (and more spacious) format to report undefined<br>
>> > errors:<br>
>> > "foo.o in archive bar.a". So, probably yes.<br>
>> ><br>
>><br>
>><br>
>> But LogName is always created with<br>
>><br>
>> F->LogName = (ArchiveName + "(" + F->LogName + ")").str();<br>
>><br>
>> So we could have a getLogName() function instead of a member variable, no?<br>
>><br>
>> Cheers,<br>
>> Rafael<br>
><br>
><br>
</div></div></blockquote></div><br></div>