diff options
author | Jay Foad <jay.foad@gmail.com> | 2009-05-21 09:52:38 +0000 |
---|---|---|
committer | Jay Foad <jay.foad@gmail.com> | 2009-05-21 09:52:38 +0000 |
commit | e3e51c0038bd6ba2add82e2246e97edec0ab2204 (patch) | |
tree | e24fe092d1dd38aa6e28777260f3aef0f9eacf46 /include/llvm/ADT/StringMap.h | |
parent | 82fe2935bf623f09533412126ad31e62dc3167ab (diff) | |
download | external_llvm-e3e51c0038bd6ba2add82e2246e97edec0ab2204.tar.gz external_llvm-e3e51c0038bd6ba2add82e2246e97edec0ab2204.tar.bz2 external_llvm-e3e51c0038bd6ba2add82e2246e97edec0ab2204.zip |
Use v.data() instead of &v[0] when SmallVector v might be empty.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72210 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/ADT/StringMap.h')
-rw-r--r-- | include/llvm/ADT/StringMap.h | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/include/llvm/ADT/StringMap.h b/include/llvm/ADT/StringMap.h index f5394750f2..a15d24eeae 100644 --- a/include/llvm/ADT/StringMap.h +++ b/include/llvm/ADT/StringMap.h @@ -286,8 +286,7 @@ public: return find(Key, Key + strlen(Key)); } iterator find(const std::string &Key) { - const char* key_start = (Key.empty() ? NULL : &Key[0]); - return find(key_start, key_start + Key.size()); + return find(Key.data(), Key.data() + Key.size()); } const_iterator find(const char *KeyStart, const char *KeyEnd) const { @@ -299,8 +298,7 @@ public: return find(Key, Key + strlen(Key)); } const_iterator find(const std::string &Key) const { - const char* key_start = (Key.empty() ? NULL : &Key[0]); - return find(key_start, key_start + Key.size()); + return find(Key.data(), Key.data() + Key.size()); } /// lookup - Return the entry for the specified key, or a default @@ -328,8 +326,7 @@ public: return GetOrCreateValue(Key, Key + strlen(Key)).getValue(); } ValueTy& operator[](const std::string &Key) { - const char* key_start = (Key.empty() ? NULL : &Key[0]); - return GetOrCreateValue(key_start, key_start + Key.size()).getValue(); + return GetOrCreateValue(Key.data(), Key.data() + Key.size()).getValue(); } size_type count(const char *KeyStart, const char *KeyEnd) const { @@ -339,8 +336,7 @@ public: return count(Key, Key + strlen(Key)); } size_type count(const std::string &Key) const { - const char* key_start = (Key.empty() ? NULL : &Key[0]); - return count(key_start, key_start + Key.size()); + return count(Key.data(), Key.data() + Key.size()); } /// insert - Insert the specified key/value pair into the map. If the key |