[PATCH] D23981: Add StringRef::scan_between

Zachary Turner via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 29 15:13:02 PDT 2016

zturner added a comment.

In https://reviews.llvm.org/D23981#528294, @majnemer wrote:

> TBH, this seems like a rather specialized use case of StringRef...  I don't think it is appropriate to grow this sort of parsing machinery here.
> I'd avoid making it a member of the general interface and just sink this method into your particular use case as a function.

I think searching for a substring and dropping everything before or after the substring is very common.  Perhaps scanning for a section *between* two substrings is specialized, but I don't agree about the single delimeter case.  So what about `scan_before()` and `scan_after()`?  This way `scan_between(X, Y)` becomes `scan_after(X).scan_before(Y)`.  And perhaps the edge cases are easier to hash out with the simpler parameter list.


More information about the llvm-commits mailing list