Skip to content

Commit c4e538a

Browse files
committed
Minor improvement
1 parent 02293fb commit c4e538a

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed

llvm/include/llvm/Support/PropertySetIO.h

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
#include <map>
4444
#include <memory>
4545
#include <string>
46+
#include <type_traits>
4647

4748
namespace llvm {
4849
namespace util {
@@ -191,18 +192,12 @@ class PropertySetRegistry {
191192

192193
// Function for bulk addition of an entire property set under given category
193194
// (property set name).
194-
template <typename T>
195-
void add(StringRef Category, const std::map<StringRef, T> &Props) {
196-
assert(PropSetMap.find(Category) == PropSetMap.end() &&
197-
"category already added");
198-
auto &PropSet = PropSetMap[Category];
195+
template <typename MapTy> void add(StringRef Category, const MapTy &Props) {
196+
using KeyTy = typename MapTy::value_type::first_type;
197+
static_assert(std::is_same<typename std::remove_const<KeyT>::type,
198+
llvm::StringRef>::value,
199+
"wrong key type");
199200

200-
for (const auto &Prop : Props)
201-
PropSet.insert(std::make_pair(Prop.first, PropertyValue(Prop.second)));
202-
}
203-
204-
template <typename T>
205-
void add(StringRef Category, const MapVector<StringRef, T> &Props) {
206201
assert(PropSetMap.find(Category) == PropSetMap.end() &&
207202
"category already added");
208203
auto &PropSet = PropSetMap[Category];

0 commit comments

Comments
 (0)