[cfe-dev] [patch] Add configure option for C include search path
Daniel Dunbar
daniel at zuster.org
Thu Nov 12 16:20:12 PST 2009
Hi Rafael,
On Thu, Nov 12, 2009 at 3:05 PM, Rafael Espindola <espindola at google.com> wrote:
>> Assuming you agree with empty string -> empty list, this is simpler as:
>> --
>> void llvm::StringRef::split(std::vector<StringRef> &A,
>> StringRef Separators, unsigned MaxSplit,
>> bool KeepEmpty) const {
>> StringRef Str = *this;
>>
>> while (!Str.empty() && A.size() != MaxSplit) {
>> std::pair<llvm::StringRef, llvm::StringRef> split = Str.split(Separators);
>>
>> if (KeepEmptyLines || !split.first.empty())
>> A.push_back(split.first);
>>
>> Str = split.second;
>> }
>> }
>
> Not for every input:
>
> *) If A is not empty at function entry...
>
> *) It also changes what is done with the tail:
> StringRef("a,b,c"),splits(parts, ",", 1). This produces ["a",
> "b,c"] with my implementation, but ["a"] with yours. Python includes
> the tail.
Good points.
>
> *) The case with KeepEmpty = false I referred to:
> StringRef("a,,b,c").split(parts, ",", 2, false); This will produce
> ["a", "b,c"] with my implementation, but ["a", "b"] with yours.
>
> I have simplified the code a bit.
Cool. Looks good to me, with MaxSpilts -> MaxSplits though.
Thanks!
- Daniel
More information about the cfe-dev
mailing list