Ping

On Thu, May 23, 2013 at 11:20 AM, Manuel Klimek <[email protected]> wrote:

> On Wed, May 22, 2013 at 11:41 PM, Richard Smith <[email protected]>wrote:
>
>> On Wed, May 22, 2013 at 9:20 AM, Jordan Rose <[email protected]>wrote:
>>
>>>
>>>   You can tokenize without a lexer, but the line/caret combo might
>>> actually be better. Nice work!
>>>
>>>
>>> ================
>>> Comment at: lib/Basic/SourceLocation.cpp:70-71
>>> @@ +69,4 @@
>>> +  StringRef Buffer = SM.getBufferData(LocInfo.first);
>>> +  int First = std::max<int>(Buffer.rfind('\n', LocInfo.second) + 1, 0);
>>> +  int Last = std::min<int>(Buffer.find('\n', LocInfo.second),
>>> Buffer.size());
>>> +  OS << "|" << Buffer.substr(First, Last - First) << "|\n" << IndentStr
>>> ----------------
>>> Not super-happy about relying on the value of StringRef::npos here, but
>>> okay.
>>>
>>
>> Aren't these min/max calls both redundant? Assuming we're not dealing
>> with buffers longer than 2^31 characters, they're equivalent to:
>>
>> int First = Buffer.rfind('\n', LocInfo.second) + 1; // because this is
>> never negative
>> int Last = Buffer.find('\n', LocInfo.second); // because this is never >=
>> Buffer.size() after conversion to int
>>
>>
> These are both exactly what was wanted, but should be of type size_t (==
>> StringRef::size_type).
>>
>
> They were left-overs that I didn't actually want to rely on, but forgot to
> clean up :) I think the latest version is easier to understand, ptal...
>
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to