[llvm-commits] [llvm] r82343 - /llvm/trunk/include/llvm/ADT/StringRef.h

Daniel Dunbar daniel at zuster.org
Sun Sep 20 14:23:44 PDT 2009


On Sat, Sep 19, 2009 at 5:38 PM, Chris Lattner <sabre at nondot.org> wrote:
> Author: lattner
> Date: Sat Sep 19 19:38:28 2009
> New Revision: 82343
>
> URL: http://llvm.org/viewvc/llvm-project?rev=82343&view=rev
> Log:
> add size_t and a version of rfind that allows specification of where
> to scan from.

Ok.

>     ///
>     /// \return - The index of the last occurence of \arg C, or npos if not
>     /// found.
> -    size_t rfind(char C) const {
> -      for (size_t i = Length, e = 0; i != e;) {
> +    size_t rfind(char C, size_t From) const {
> +      for (size_t i = From, e = 0; i != e;) {
>         --i;
>         if (Data[i] == C)
>           return i;
>       }
>       return npos;
>     }
> +
> +    size_t rfind(char C) const {
> +      return rfind(C, Length);
> +    }
> +

To be in line with the current API, this should be one method with the
default argument for From being StringRef::npos, and the starting
position should be the minimum of the current Length and the From
argument.

 - Daniel




More information about the llvm-commits mailing list