diff options
author | Chris Lattner <sabre@nondot.org> | 2009-07-26 17:46:03 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-07-26 17:46:03 +0000 |
commit | 7e763ebd982e199224a2d2e0cc802d09d2822b34 (patch) | |
tree | 59a5b969ba6243d0f922705b1df04fa9508a9395 /include/llvm/ADT/StringRef.h | |
parent | f9474ca92802228bb792d92dbeb4ef5ba7ecc203 (diff) | |
download | external_llvm-7e763ebd982e199224a2d2e0cc802d09d2822b34.zip external_llvm-7e763ebd982e199224a2d2e0cc802d09d2822b34.tar.gz external_llvm-7e763ebd982e199224a2d2e0cc802d09d2822b34.tar.bz2 |
Use the RHS length instead of the LHS length. They are both the same,
but this ends up compiling code like this:
int foo(const StringRef &R) {
return R == "food";
}
to use a constant sized memcmp instead of a variable memcmp.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@77160 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/ADT/StringRef.h')
-rw-r--r-- | include/llvm/ADT/StringRef.h | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/include/llvm/ADT/StringRef.h b/include/llvm/ADT/StringRef.h index 5f3e5fb..0b1bfb2 100644 --- a/include/llvm/ADT/StringRef.h +++ b/include/llvm/ADT/StringRef.h @@ -81,7 +81,7 @@ namespace llvm { /// compare() in when the relative ordering of inequal strings isn't needed. bool equals(const StringRef &RHS) const { return (Length == RHS.Length && - memcmp(Data, RHS.Data, Length) == 0); + memcmp(Data, RHS.Data, RHS.Length) == 0); } /// compare - Compare two strings; the result is -1, 0, or 1 if this string |