Changeset 167592 in webkit
- Timestamp:
- Apr 21, 2014 8:52:27 AM (10 years ago)
- Location:
- trunk
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WTF/ChangeLog
r167577 r167592 1 2014-04-21 Darin Adler <darin@apple.com> 2 3 Add HashSet::takeAny 4 https://bugs.webkit.org/show_bug.cgi?id=131928 5 6 Reviewed by Benjamin Poulain. 7 8 * wtf/HashSet.h: Added an overload of take that takes an iterator, 9 and used it to implement both the existing take and new takeAny functions. 10 1 11 2014-04-20 Andreas Kling <akling@apple.com> 2 12 -
trunk/Source/WTF/wtf/HashSet.h
r161801 r167592 104 104 105 105 ValueType take(const ValueType&); 106 ValueType take(iterator); 107 ValueType takeAny(); 106 108 107 109 static bool isValidValue(const ValueType&); … … 241 243 242 244 template<typename T, typename U, typename V> 243 auto HashSet<T, U, V>::take(const ValueType& value) -> ValueType 244 { 245 auto it = find(value); 245 inline auto HashSet<T, U, V>::take(iterator it) -> ValueType 246 { 246 247 if (it == end()) 247 248 return ValueTraits::emptyValue(); … … 250 251 remove(it); 251 252 return result; 253 } 254 255 template<typename T, typename U, typename V> 256 inline auto HashSet<T, U, V>::take(const ValueType& value) -> ValueType 257 { 258 return take(find(value)); 259 } 260 261 template<typename T, typename U, typename V> 262 inline auto HashSet<T, U, V>::takeAny() -> ValueType 263 { 264 return take(begin()); 252 265 } 253 266 -
trunk/Source/WebCore/ChangeLog
r167590 r167592 1 2014-04-21 Darin Adler <darin@apple.com> 2 3 Add HashSet::takeAny 4 https://bugs.webkit.org/show_bug.cgi?id=131928 5 6 Reviewed by Benjamin Poulain. 7 8 * dom/Document.cpp: 9 (WebCore::Document::takeAnyMediaCanStartListener): Use HashSet::takeAny. 10 * dom/ScriptExecutionContext.cpp: 11 (WebCore::takeAny): Deleted. 12 (WebCore::ScriptExecutionContext::~ScriptExecutionContext): Use HashSet::takeAny. 13 1 14 2014-04-21 Zan Dobersek <zdobersek@igalia.com> 2 15 -
trunk/Source/WebCore/dom/Document.cpp
r167497 r167592 5086 5086 MediaCanStartListener* Document::takeAnyMediaCanStartListener() 5087 5087 { 5088 HashSet<MediaCanStartListener*>::iterator slot = m_mediaCanStartListeners.begin(); 5089 if (slot == m_mediaCanStartListeners.end()) 5090 return nullptr; 5091 MediaCanStartListener* listener = *slot; 5092 m_mediaCanStartListeners.remove(slot); 5093 return listener; 5088 return m_mediaCanStartListeners.takeAny(); 5094 5089 } 5095 5090 -
trunk/Source/WebCore/dom/ScriptExecutionContext.cpp
r167579 r167592 106 106 } 107 107 108 // FIXME: We should make this a member function of HashSet.109 template<typename T> inline T takeAny(HashSet<T>& set)110 {111 ASSERT(!set.isEmpty());112 auto iterator = set.begin();113 T result = std::move(*iterator);114 set.remove(iterator);115 return result;116 }117 118 108 #if ASSERT_DISABLED 119 109 … … 148 138 #endif 149 139 150 while ( !m_destructionObservers.isEmpty())151 takeAny(m_destructionObservers)->contextDestroyed();140 while (auto* destructionObserver = m_destructionObservers.takeAny()) 141 destructionObserver->contextDestroyed(); 152 142 153 143 for (auto* messagePort : m_messagePorts) -
trunk/Tools/ChangeLog
r167576 r167592 1 2014-04-21 Darin Adler <darin@apple.com> 2 3 Add HashSet::takeAny 4 https://bugs.webkit.org/show_bug.cgi?id=131928 5 6 Reviewed by Benjamin Poulain. 7 8 * TestWebKitAPI/Tests/WTF/HashSet.cpp: Added a test for takeAny. 9 1 10 2014-04-20 Dan Bernstein <mitz@apple.com> 2 11 -
trunk/Tools/TestWebKitAPI/Tests/WTF/HashSet.cpp
r155580 r167592 102 102 EXPECT_TRUE(hashSet.take(MoveOnly(i + 1)) == MoveOnly(i + 1)); 103 103 104 EXPECT_TRUE(hashSet.isEmpty()); 105 106 for (size_t i = 0; i < 100; ++i) 107 hashSet.add(std::move(MoveOnly(i + 1))); 108 109 HashSet<MoveOnly> secondSet; 110 111 for (size_t i = 0; i < 100; ++i) 112 secondSet.add(hashSet.takeAny()); 113 114 EXPECT_TRUE(hashSet.isEmpty()); 115 116 for (size_t i = 0; i < 100; ++i) 117 EXPECT_TRUE(secondSet.contains(MoveOnly(i + 1))); 104 118 } 105 119
Note: See TracChangeset
for help on using the changeset viewer.