[llvm-commits] [PATCH][Support/StringRef] Add rtrim.

Michael Spencer bigcheesegs at gmail.com
Fri May 11 12:10:12 PDT 2012


On Thu, May 10, 2012 at 12:36 PM, Benjamin Kramer
<benny.kra at googlemail.com> wrote:
>
> On 10.05.2012, at 21:20, Michael Spencer wrote:
>
>> On Thu, May 10, 2012 at 12:07 AM, Benjamin Kramer
>> <benny.kra at googlemail.com> wrote:
>>> On 10.05.2012, at 01:37, Michael Spencer <bigcheesegs at gmail.com> wrote:
>>>
>>>> I need rtrim (right trim) for the YAML parser.
>>>>
>>>> An alternative implementation would be to add rfind_first_not_of and
>>>> then implement in terms of that.
>>>
>>> Don't we already have StringRef::find_last_not_of?
>>>
>>> -Ben
>>
>> No. Would you rather see that added? Or rtrim implemented in terms of it?
>
> We already have find_first_of, find_first_not_of and find_last_of, which follow the semantics of the corresponding functions of std::string. find_last_not_of is probably missing because nobody needed it before. It makes a lot of sense to add it.
>
> Then rtrim can be a small convenience wrapper on top of it. If we have rtrim we probably also want ltrim for consistency.
>
> - Ben

New patch attached.

- Michael Spencer
-------------- next part --------------
A non-text attachment was scrubbed...
Name: trim.patch
Type: application/octet-stream
Size: 4157 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20120511/c17de318/attachment.obj>


More information about the llvm-commits mailing list