Skip to content
Permalink
Browse files
Remove HashCountedSet's copyToVector functions
https://bugs.webkit.org/show_bug.cgi?id=178215

Patch by Sam Weinig <sam@webkit.org> on 2017-10-14
Reviewed by Daniel Bates.

Source/WebCore:

* page/DeviceController.cpp:
(WebCore::DeviceController::dispatchDeviceEvent):
(WebCore::DeviceController::fireDeviceEvent):

    Replace use of HashCountedSet's copyToVector functions with copyToVector(hashCountedSet.values()).

Source/WTF:

* wtf/HashCountedSet.h:
(WTF::copyToVector): Deleted.

    They are replaced by either copyToVector(hashCountedSet) or copyToVector(hashCountedSet.values())

Canonical link: https://commits.webkit.org/194524@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@223317 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
Sam Weinig authored and webkit-commit-queue committed Oct 14, 2017
1 parent bfce48e commit cfcb3a0e48bbe7bef60bf489e913d967d2ea05ba
Showing 4 changed files with 27 additions and 33 deletions.
@@ -1,3 +1,15 @@
2017-10-14 Sam Weinig <sam@webkit.org>

Remove HashCountedSet's copyToVector functions
https://bugs.webkit.org/show_bug.cgi?id=178215

Reviewed by Daniel Bates.

* wtf/HashCountedSet.h:
(WTF::copyToVector): Deleted.

They are replaced by either copyToVector(hashCountedSet) or copyToVector(hashCountedSet.values())

2017-10-13 Sam Weinig <sam@webkit.org>

Adopt type trait template aliases everywhere in WTF
@@ -309,34 +309,6 @@ inline auto HashCountedSet<Value, HashFunctions, Traits>::remove(typename GetPtr
return remove(find(value));
}

template<typename Value, typename HashFunctions, typename Traits, typename VectorType>
inline void copyToVector(const HashCountedSet<Value, HashFunctions, Traits>& collection, VectorType& vector)
{
typedef typename HashCountedSet<Value, HashFunctions, Traits>::const_iterator iterator;

vector.resize(collection.size());

iterator it = collection.begin();
iterator end = collection.end();
for (unsigned i = 0; it != end; ++it, ++i)
vector[i] = *it;
}

template<typename Value, typename HashFunctions, typename Traits>
inline void copyToVector(const HashCountedSet<Value, HashFunctions, Traits>& collection, Vector<Value>& vector)
{
typedef typename HashCountedSet<Value, HashFunctions, Traits>::const_iterator iterator;

vector.resize(collection.size());

iterator it = collection.begin();
iterator end = collection.end();
for (unsigned i = 0; it != end; ++it, ++i)
vector[i] = (*it).key;
}

} // namespace WTF

using WTF::HashCountedSet;


@@ -1,3 +1,16 @@
2017-10-14 Sam Weinig <sam@webkit.org>

Remove HashCountedSet's copyToVector functions
https://bugs.webkit.org/show_bug.cgi?id=178215

Reviewed by Daniel Bates.

* page/DeviceController.cpp:
(WebCore::DeviceController::dispatchDeviceEvent):
(WebCore::DeviceController::fireDeviceEvent):

Replace use of HashCountedSet's copyToVector functions with copyToVector(hashCountedSet.values()).

2017-10-13 Jer Noble <jer.noble@apple.com>

Performance: Skip texture upload if source image and destination texture haven't changed
@@ -72,9 +72,7 @@ void DeviceController::removeAllDeviceEventListeners(DOMWindow* window)

void DeviceController::dispatchDeviceEvent(Event& event)
{
Vector<RefPtr<DOMWindow>> listenerVector;
copyToVector(m_listeners, listenerVector);
for (auto& listener : listenerVector) {
for (auto& listener : copyToVector(m_listeners.values())) {
auto document = listener->document();
if (document && !document->activeDOMObjectsAreSuspended() && !document->activeDOMObjectsAreStopped())
listener->dispatchEvent(event);
@@ -86,8 +84,7 @@ void DeviceController::fireDeviceEvent()
ASSERT(hasLastData());

m_timer.stop();
Vector<RefPtr<DOMWindow>> listenerVector;
copyToVector(m_lastEventListeners, listenerVector);
auto listenerVector = copyToVector(m_lastEventListeners.values());
m_lastEventListeners.clear();
for (auto& listener : listenerVector) {
auto document = listener->document();

0 comments on commit cfcb3a0

Please sign in to comment.