aboutsummaryrefslogtreecommitdiffstats
path: root/include/llvm/ADT
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-07-26 17:46:03 +0000
committerChris Lattner <sabre@nondot.org>2009-07-26 17:46:03 +0000
commitaf410c5812434b3d4bab13ad75b06bb42098efb1 (patch)
tree59a5b969ba6243d0f922705b1df04fa9508a9395 /include/llvm/ADT
parentcd7de3ee37ec3c1f9be3ba5899af1d7091556274 (diff)
downloadexternal_llvm-af410c5812434b3d4bab13ad75b06bb42098efb1.zip
external_llvm-af410c5812434b3d4bab13ad75b06bb42098efb1.tar.gz
external_llvm-af410c5812434b3d4bab13ad75b06bb42098efb1.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')
-rw-r--r--include/llvm/ADT/StringRef.h2
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