Changeset 24059 in webkit for trunk/JavaScriptCore/wtf/HashMap.h
- Timestamp:
- Jul 6, 2007, 5:09:08 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/wtf/HashMap.h
r21468 r24059 112 112 }; 113 113 114 template<bool canReplaceDeletedKey, typename ValueType, typename Value StorageTraits, typename HashFunctions>114 template<bool canReplaceDeletedKey, typename ValueType, typename ValueTraits, typename ValueStorageTraits, typename HashFunctions> 115 115 struct HashMapTranslator; 116 116 117 template<typename ValueType, typename Value StorageTraits, typename HashFunctions>118 struct HashMapTranslator<true, ValueType, Value StorageTraits, HashFunctions> {117 template<typename ValueType, typename ValueTraits, typename ValueStorageTraits, typename HashFunctions> 118 struct HashMapTranslator<true, ValueType, ValueTraits, ValueStorageTraits, HashFunctions> { 119 119 typedef typename ValueType::first_type KeyType; 120 120 typedef typename ValueType::second_type MappedType; … … 122 122 typedef typename ValueStorageTraits::FirstTraits KeyStorageTraits; 123 123 typedef typename KeyStorageTraits::TraitType KeyStorageType; 124 typedef typename ValueStorageTraits::SecondTraits MappedStorageTraits; 125 typedef typename MappedStorageTraits::TraitType MappedStorageType; 126 typedef typename ValueTraits::FirstTraits KeyTraits; 127 typedef typename ValueTraits::SecondTraits MappedTraits; 124 128 125 129 static unsigned hash(const KeyType& key) { return HashFunctions::hash(key); } … … 127 131 static void translate(ValueStorageType& location, const KeyType& key, const MappedType& mapped, unsigned) 128 132 { 129 *(KeyType*)&location.first = key;130 *(MappedType*)&location.second = mapped;133 Assigner<KeyTraits::needsRef, KeyType, KeyStorageType, KeyTraits>::assign(key, location.first); 134 Assigner<MappedTraits::needsRef, MappedType, MappedStorageType, MappedTraits>::assign(mapped, location.second); 131 135 } 132 136 }; 133 137 134 template<typename ValueType, typename Value StorageTraits, typename HashFunctions>135 struct HashMapTranslator<false, ValueType, Value StorageTraits, HashFunctions> {138 template<typename ValueType, typename ValueTraits, typename ValueStorageTraits, typename HashFunctions> 139 struct HashMapTranslator<false, ValueType, ValueTraits, ValueStorageTraits, HashFunctions> { 136 140 typedef typename ValueType::first_type KeyType; 137 141 typedef typename ValueType::second_type MappedType; … … 139 143 typedef typename ValueStorageTraits::FirstTraits KeyStorageTraits; 140 144 typedef typename KeyStorageTraits::TraitType KeyStorageType; 141 145 typedef typename ValueStorageTraits::SecondTraits MappedStorageTraits; 146 typedef typename MappedStorageTraits::TraitType MappedStorageType; 147 typedef typename ValueTraits::FirstTraits KeyTraits; 148 typedef typename ValueTraits::SecondTraits MappedTraits; 149 142 150 static unsigned hash(const KeyType& key) { return HashFunctions::hash(key); } 143 151 static bool equal(const KeyStorageType& a, const KeyType& b) { return HashFunctions::equal(*(KeyType*)&a, b); } … … 146 154 if (location.first == KeyStorageTraits::deletedValue()) 147 155 location.first = KeyStorageTraits::emptyValue(); 148 *(KeyType*)&location.first = key;149 *(MappedType*)&location.second = mapped;156 Assigner<KeyTraits::needsRef, KeyType, KeyStorageType, KeyTraits>::assign(key, location.first); 157 Assigner<MappedTraits::needsRef, MappedType, MappedStorageType, MappedTraits>::assign(mapped, location.second); 150 158 } 151 159 }; … … 260 268 { 261 269 const bool canReplaceDeletedKey = !KeyTraits::needsDestruction || KeyStorageTraits::needsDestruction; 262 typedef HashMapTranslator<canReplaceDeletedKey, ValueType, Value StorageTraits, HashFunctions> TranslatorType;270 typedef HashMapTranslator<canReplaceDeletedKey, ValueType, ValueTraits, ValueStorageTraits, HashFunctions> TranslatorType; 263 271 return m_impl.template add<KeyType, MappedType, TranslatorType>(key, mapped); 264 272 }
Note:
See TracChangeset
for help on using the changeset viewer.