[PATCH] Added const qualifier to StringRef::edit_distance member function

Ismail Pazarbasi ismail.pazarbasi at gmail.com
Fri Aug 23 18:05:37 PDT 2013


Hi bkramer,

I tried to call edit_distance member function of a const StringRef object. edit_distance member function does not mutate the object, therefore can be const qualified (or can be a static member function).

http://llvm-reviews.chandlerc.com/D1502

Files:
  include/llvm/ADT/StringRef.h
  lib/Support/StringRef.cpp

Index: include/llvm/ADT/StringRef.h
===================================================================
--- include/llvm/ADT/StringRef.h
+++ include/llvm/ADT/StringRef.h
@@ -175,7 +175,7 @@
     /// transform one of the given strings into the other. If zero,
     /// the strings are identical.
     unsigned edit_distance(StringRef Other, bool AllowReplacements = true,
-                           unsigned MaxEditDistance = 0);
+                           unsigned MaxEditDistance = 0) const;
 
     /// str - Get the contents as an std::string.
     std::string str() const {
Index: lib/Support/StringRef.cpp
===================================================================
--- lib/Support/StringRef.cpp
+++ lib/Support/StringRef.cpp
@@ -85,7 +85,7 @@
 // Compute the edit distance between the two given strings.
 unsigned StringRef::edit_distance(llvm::StringRef Other,
                                   bool AllowReplacements,
-                                  unsigned MaxEditDistance) {
+                                  unsigned MaxEditDistance) const {
   return llvm::ComputeEditDistance(
       llvm::ArrayRef<char>(data(), size()),
       llvm::ArrayRef<char>(Other.data(), Other.size()),
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D1502.1.patch
Type: text/x-patch
Size: 1207 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130823/207d9e31/attachment.bin>


More information about the cfe-commits mailing list