diff options
author | Nathan James <n.james93@hotmail.co.uk> | 2022-06-05 12:03:08 +0100 |
---|---|---|
committer | Nathan James <n.james93@hotmail.co.uk> | 2022-06-05 12:03:09 +0100 |
commit | a13b61f7f0a2a44546fb39663b0d6f2547841e02 (patch) | |
tree | 84bcb51c759ce3b6cc443ddf931ca7216094f2d0 /llvm/lib/Support/StringRef.cpp | |
parent | 95a134254a403750ddfee7c056efdf2359a7dc8c (diff) | |
download | llvm-a13b61f7f0a2a44546fb39663b0d6f2547841e02.zip llvm-a13b61f7f0a2a44546fb39663b0d6f2547841e02.tar.gz llvm-a13b61f7f0a2a44546fb39663b0d6f2547841e02.tar.bz2 |
[ADT] Add edit_distance_insensitive to StringRef
In some instances its advantageous to calculate edit distances without worrying about casing.
Currently to achieve this both strings need to be converted to the same case first, then edit distance can be calculated.
Reviewed By: dblaikie
Differential Revision: https://reviews.llvm.org/D126159
Diffstat (limited to 'llvm/lib/Support/StringRef.cpp')
-rw-r--r-- | llvm/lib/Support/StringRef.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/llvm/lib/Support/StringRef.cpp b/llvm/lib/Support/StringRef.cpp index 3ed08ed..096b2d2 100644 --- a/llvm/lib/Support/StringRef.cpp +++ b/llvm/lib/Support/StringRef.cpp @@ -98,6 +98,13 @@ unsigned StringRef::edit_distance(llvm::StringRef Other, AllowReplacements, MaxEditDistance); } +unsigned llvm::StringRef::edit_distance_insensitive( + StringRef Other, bool AllowReplacements, unsigned MaxEditDistance) const { + return llvm::ComputeMappedEditDistance( + makeArrayRef(data(), size()), makeArrayRef(Other.data(), Other.size()), + llvm::toLower, AllowReplacements, MaxEditDistance); +} + //===----------------------------------------------------------------------===// // String Operations //===----------------------------------------------------------------------===// |