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

Benjamin Kramer benny.kra at googlemail.com
Thu May 10 12:36:31 PDT 2012


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



More information about the llvm-commits mailing list