Commit 64f1b5a3 authored by andersca@apple.com's avatar andersca@apple.com

Remove NonCopyableSort.h from WTF

https://bugs.webkit.org/show_bug.cgi?id=120984

Reviewed by Andreas Kling.

Source/WebCore:

* css/MediaQuery.cpp:
(WebCore::MediaQuery::MediaQuery):
* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::updateActiveTextTrackCues):
* html/RangeInputType.cpp:
(WebCore::RangeInputType::updateTickMarkValues):
* inspector/InspectorMemoryAgent.cpp:
* page/CaptionUserPreferences.cpp:
(WebCore::CaptionUserPreferences::sortedTrackListForMenu):
* page/CaptionUserPreferences.h:
* page/CaptionUserPreferencesMediaAF.cpp:
(WebCore::CaptionUserPreferencesMediaAF::sortedTrackListForMenu):
* platform/graphics/texmap/TextureMapper.cpp:
(WebCore::BitmapTexturePool::releaseUnusedTexturesTimerFired):

Source/WebKit/blackberry:

* WebKitSupport/RenderQueue.cpp:
(BlackBerry::WebKit::RenderQueue::quickSort):

Source/WTF:

std::sort as defined by C++11 moves elements when possible, so there's no need for nonCopyableSort anymore.

* GNUmakefile.list.am:
* WTF.pro:
* WTF.vcxproj/WTF.vcxproj:
* WTF.vcxproj/WTF.vcxproj.filters:
* WTF.xcodeproj/project.pbxproj:
* wtf/NonCopyingSort.h: Removed.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@155277 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 3a182c79
2013-09-07 Anders Carlsson <andersca@apple.com>
Remove NonCopyableSort.h from WTF
https://bugs.webkit.org/show_bug.cgi?id=120984
Reviewed by Andreas Kling.
std::sort as defined by C++11 moves elements when possible, so there's no need for nonCopyableSort anymore.
* GNUmakefile.list.am:
* WTF.pro:
* WTF.vcxproj/WTF.vcxproj:
* WTF.vcxproj/WTF.vcxproj.filters:
* WTF.xcodeproj/project.pbxproj:
* wtf/NonCopyingSort.h: Removed.
2013-09-07 Anders Carlsson <andersca@apple.com>
Get rid of PassOwnArrayPtr
......
......@@ -91,7 +91,6 @@ wtf_sources += \
Source/WTF/wtf/MetaAllocatorHandle.h \
Source/WTF/wtf/NeverDestroyed.h \
Source/WTF/wtf/NoLock.h \
Source/WTF/wtf/NonCopyingSort.h \
Source/WTF/wtf/Noncopyable.h \
Source/WTF/wtf/NotFound.h \
Source/WTF/wtf/NullPtr.h \
......
......@@ -88,7 +88,6 @@ HEADERS += \
MetaAllocatorHandle.h \
Ref.h \
Noncopyable.h \
NonCopyingSort.h \
NotFound.h \
NullPtr.h \
NumberOfCores.h \
......
......@@ -192,7 +192,6 @@
<ClInclude Include="..\wtf\MetaAllocatorHandle.h" />
<ClInclude Include="..\wtf\NeverDestroyed.h" />
<ClInclude Include="..\wtf\Noncopyable.h" />
<ClInclude Include="..\wtf\NonCopyingSort.h" />
<ClInclude Include="..\wtf\NotFound.h" />
<ClInclude Include="..\wtf\NullPtr.h" />
<ClInclude Include="..\wtf\NumberOfCores.h" />
......
......@@ -500,9 +500,6 @@
<ClInclude Include="..\wtf\Noncopyable.h">
<Filter>wtf</Filter>
</ClInclude>
<ClInclude Include="..\wtf\NonCopyingSort.h">
<Filter>wtf</Filter>
</ClInclude>
<ClInclude Include="..\wtf\NotFound.h">
<Filter>wtf</Filter>
</ClInclude>
......
......@@ -157,7 +157,6 @@
A8A473ED151A825B004123FF /* MetaAllocator.h in Headers */ = {isa = PBXBuildFile; fileRef = A8A472CE151A825B004123FF /* MetaAllocator.h */; };
A8A473EE151A825B004123FF /* MetaAllocatorHandle.h in Headers */ = {isa = PBXBuildFile; fileRef = A8A472CF151A825B004123FF /* MetaAllocatorHandle.h */; };
A8A473EF151A825B004123FF /* Noncopyable.h in Headers */ = {isa = PBXBuildFile; fileRef = A8A472D0151A825B004123FF /* Noncopyable.h */; };
A8A473F0151A825B004123FF /* NonCopyingSort.h in Headers */ = {isa = PBXBuildFile; fileRef = A8A472D1151A825B004123FF /* NonCopyingSort.h */; };
A8A473F1151A825B004123FF /* NotFound.h in Headers */ = {isa = PBXBuildFile; fileRef = A8A472D2151A825B004123FF /* NotFound.h */; };
A8A473F2151A825B004123FF /* NullPtr.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A8A472D3151A825B004123FF /* NullPtr.cpp */; };
A8A473F3151A825B004123FF /* NullPtr.h in Headers */ = {isa = PBXBuildFile; fileRef = A8A472D4151A825B004123FF /* NullPtr.h */; };
......@@ -432,7 +431,6 @@
A8A472CE151A825B004123FF /* MetaAllocator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MetaAllocator.h; sourceTree = "<group>"; };
A8A472CF151A825B004123FF /* MetaAllocatorHandle.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MetaAllocatorHandle.h; sourceTree = "<group>"; };
A8A472D0151A825B004123FF /* Noncopyable.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Noncopyable.h; sourceTree = "<group>"; };
A8A472D1151A825B004123FF /* NonCopyingSort.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NonCopyingSort.h; sourceTree = "<group>"; };
A8A472D2151A825B004123FF /* NotFound.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NotFound.h; sourceTree = "<group>"; };
A8A472D3151A825B004123FF /* NullPtr.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NullPtr.cpp; sourceTree = "<group>"; };
A8A472D4151A825B004123FF /* NullPtr.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NullPtr.h; sourceTree = "<group>"; };
......@@ -709,7 +707,6 @@
26299B6D17A9E5B800ADEBE5 /* Ref.h */,
0F0D85B317234CB100338210 /* NoLock.h */,
A8A472D0151A825B004123FF /* Noncopyable.h */,
A8A472D1151A825B004123FF /* NonCopyingSort.h */,
A8A472D2151A825B004123FF /* NotFound.h */,
A8A472D3151A825B004123FF /* NullPtr.cpp */,
A8A472D4151A825B004123FF /* NullPtr.h */,
......@@ -1013,7 +1010,6 @@
A8A473EE151A825B004123FF /* MetaAllocatorHandle.h in Headers */,
0F0D85B417234CC100338210 /* NoLock.h in Headers */,
A8A473EF151A825B004123FF /* Noncopyable.h in Headers */,
A8A473F0151A825B004123FF /* NonCopyingSort.h in Headers */,
A8A473F1151A825B004123FF /* NotFound.h in Headers */,
A8A473F3151A825B004123FF /* NullPtr.h in Headers */,
A8A473F5151A825B004123FF /* NumberOfCores.h in Headers */,
......
......@@ -53,7 +53,6 @@ set(WTF_HEADERS
MessageQueue.h
MetaAllocator.h
MetaAllocatorHandle.h
NonCopyingSort.h
ThreadRestrictionVerifier.h
Ref.h
Noncopyable.h
......
/*
* Copyright (C) 2010 Apple Inc. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef WTF_NonCopyingSort_h
#define WTF_NonCopyingSort_h
namespace WTF {
using std::swap;
template<typename RandomAccessIterator, typename Predicate>
inline void siftDown(RandomAccessIterator array, ptrdiff_t start, ptrdiff_t end, Predicate compareLess)
{
ptrdiff_t root = start;
while (root * 2 + 1 <= end) {
ptrdiff_t child = root * 2 + 1;
if (child < end && compareLess(array[child], array[child + 1]))
child++;
if (compareLess(array[root], array[child])) {
swap(array[root], array[child]);
root = child;
} else
return;
}
}
template<typename RandomAccessIterator, typename Predicate>
inline void heapify(RandomAccessIterator array, ptrdiff_t count, Predicate compareLess)
{
ptrdiff_t start = (count - 2) / 2;
while (start >= 0) {
siftDown(array, start, count - 1, compareLess);
start--;
}
}
template<typename RandomAccessIterator, typename Predicate>
void heapSort(RandomAccessIterator start, RandomAccessIterator end, Predicate compareLess)
{
ptrdiff_t count = end - start;
heapify(start, count, compareLess);
ptrdiff_t endIndex = count - 1;
while (endIndex > 0) {
swap(start[endIndex], start[0]);
siftDown(start, 0, endIndex - 1, compareLess);
endIndex--;
}
}
template<typename RandomAccessIterator, typename Predicate>
inline void nonCopyingSort(RandomAccessIterator start, RandomAccessIterator end, Predicate compareLess)
{
// heapsort happens to use only swaps, not copies, but the essential thing about
// this function is the fact that it does not copy, not the specific algorithm
heapSort(start, end, compareLess);
}
} // namespace WTF
using WTF::nonCopyingSort;
#endif // WTF_NonCopyingSort_h
2013-09-07 Anders Carlsson <andersca@apple.com>
Remove NonCopyableSort.h from WTF
https://bugs.webkit.org/show_bug.cgi?id=120984
Reviewed by Andreas Kling.
* css/MediaQuery.cpp:
(WebCore::MediaQuery::MediaQuery):
* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::updateActiveTextTrackCues):
* html/RangeInputType.cpp:
(WebCore::RangeInputType::updateTickMarkValues):
* inspector/InspectorMemoryAgent.cpp:
* page/CaptionUserPreferences.cpp:
(WebCore::CaptionUserPreferences::sortedTrackListForMenu):
* page/CaptionUserPreferences.h:
* page/CaptionUserPreferencesMediaAF.cpp:
(WebCore::CaptionUserPreferencesMediaAF::sortedTrackListForMenu):
* platform/graphics/texmap/TextureMapper.cpp:
(WebCore::BitmapTexturePool::releaseUnusedTexturesTimerFired):
2013-09-07 Antti Koivisto <antti@apple.com>
Simplify ComposedShadowTreeWalker parent traversal
......@@ -30,7 +30,6 @@
#include "MediaQuery.h"
#include "MediaQueryExp.h"
#include <wtf/NonCopyingSort.h>
#include <wtf/text/StringBuilder.h>
namespace WebCore {
......@@ -78,7 +77,6 @@ static bool expressionCompare(const OwnPtr<MediaQueryExp>& a, const OwnPtr<Media
return codePointCompare(a->serialize(), b->serialize()) < 0;
}
MediaQuery::MediaQuery(Restrictor r, const String& mediaType, PassOwnPtr<ExpressionVector> exprs)
: m_restrictor(r)
, m_mediaType(mediaType.lower())
......@@ -90,7 +88,7 @@ MediaQuery::MediaQuery(Restrictor r, const String& mediaType, PassOwnPtr<Express
return;
}
nonCopyingSort(m_expressions->begin(), m_expressions->end(), expressionCompare);
std::sort(m_expressions->begin(), m_expressions->end(), expressionCompare);
// remove all duplicated expressions
String key;
......
......@@ -82,7 +82,6 @@
#include <runtime/Uint8Array.h>
#include <wtf/CurrentTime.h>
#include <wtf/MathExtras.h>
#include <wtf/NonCopyingSort.h>
#include <wtf/Ref.h>
#include <wtf/text/CString.h>
......@@ -1310,7 +1309,7 @@ void HTMLMediaElement::updateActiveTextTrackCues(double movieTime)
// 12 - Sort the tasks in events in ascending time order (tasks with earlier
// times first).
nonCopyingSort(eventTasks.begin(), eventTasks.end(), eventTimeCueCompare);
std::sort(eventTasks.begin(), eventTasks.end(), eventTimeCueCompare);
for (size_t i = 0; i < eventTasks.size(); ++i) {
if (!affectedTracks.contains(eventTasks[i].second->track()))
......@@ -1344,7 +1343,7 @@ void HTMLMediaElement::updateActiveTextTrackCues(double movieTime)
// 14 - Sort affected tracks in the same order as the text tracks appear in
// the media element's list of text tracks, and remove duplicates.
nonCopyingSort(affectedTracks.begin(), affectedTracks.end(), trackIndexCompare);
std::sort(affectedTracks.begin(), affectedTracks.end(), trackIndexCompare);
// 15 - For each text track in affected tracks, in the list order, queue a
// task to fire a simple event named cuechange at the TextTrack object, and, ...
......
......@@ -60,7 +60,6 @@
#if ENABLE(DATALIST_ELEMENT)
#include "HTMLDataListElement.h"
#include "HTMLOptionElement.h"
#include <wtf/NonCopyingSort.h>
#endif
namespace WebCore {
......@@ -348,11 +347,6 @@ void RangeInputType::listAttributeTargetChanged()
sliderTrackElement->renderer()->setNeedsLayout(true);
}
static bool decimalCompare(const Decimal& a, const Decimal& b)
{
return a < b;
}
void RangeInputType::updateTickMarkValues()
{
if (!m_tickMarkValuesDirty)
......@@ -373,7 +367,7 @@ void RangeInputType::updateTickMarkValues()
m_tickMarkValues.append(parseToNumber(optionValue, Decimal::nan()));
}
m_tickMarkValues.shrinkToFit();
nonCopyingSort(m_tickMarkValues.begin(), m_tickMarkValues.end(), decimalCompare);
std::sort(m_tickMarkValues.begin(), m_tickMarkValues.end());
}
Decimal RangeInputType::findClosestTickMarkValue(const Decimal& value)
......
......@@ -52,7 +52,6 @@
#include "StyledElement.h"
#include <runtime/ArrayBufferView.h>
#include <wtf/HashSet.h>
#include <wtf/NonCopyingSort.h>
#include <wtf/OwnPtr.h>
#include <wtf/PassOwnPtr.h>
#include <wtf/Vector.h>
......
......@@ -34,7 +34,6 @@
#include "Settings.h"
#include "TextTrackList.h"
#include "UserStyleSheetTypes.h"
#include <wtf/NonCopyingSort.h>
namespace WebCore {
......@@ -179,16 +178,17 @@ static bool textTrackCompare(const RefPtr<TextTrack>& a, const RefPtr<TextTrack>
return codePointCompare(trackDisplayName(a.get()), trackDisplayName(b.get())) < 0;
}
Vector<RefPtr<TextTrack> > CaptionUserPreferences::sortedTrackListForMenu(TextTrackList* trackList)
Vector<RefPtr<TextTrack>> CaptionUserPreferences::sortedTrackListForMenu(TextTrackList* trackList)
{
ASSERT(trackList);
Vector<RefPtr<TextTrack> > tracksForMenu;
Vector<RefPtr<TextTrack>> tracksForMenu;
for (unsigned i = 0, length = trackList->length(); i < length; ++i)
tracksForMenu.append(trackList->item(i));
nonCopyingSort(tracksForMenu.begin(), tracksForMenu.end(), textTrackCompare);
std::sort(tracksForMenu.begin(), tracksForMenu.end(), textTrackCompare);
tracksForMenu.insert(0, TextTrack::captionMenuOffItem());
tracksForMenu.insert(1, TextTrack::captionMenuAutomaticItem());
......
......@@ -79,7 +79,7 @@ public:
virtual Vector<String> preferredLanguages() const;
virtual String displayNameForTrack(TextTrack*) const;
virtual Vector<RefPtr<TextTrack> > sortedTrackListForMenu(TextTrackList*);
virtual Vector<RefPtr<TextTrack>> sortedTrackListForMenu(TextTrackList*);
void setPrimaryAudioTrackLanguageOverride(const String& language) { m_primaryAudioTrackLanguageOverride = language; }
String primaryAudioTrackLanguageOverride() const;
......
......@@ -45,7 +45,6 @@
#include "TextTrackCue.h"
#include "TextTrackList.h"
#include "UserStyleSheetTypes.h"
#include <wtf/NonCopyingSort.h>
#include <wtf/RetainPtr.h>
#include <wtf/text/StringBuilder.h>
......@@ -845,7 +844,7 @@ Vector<RefPtr<TextTrack> > CaptionUserPreferencesMediaAF::sortedTrackListForMenu
}
}
nonCopyingSort(tracksForMenu.begin(), tracksForMenu.end(), textTrackCompare);
std::sort(tracksForMenu.begin(), tracksForMenu.end(), textTrackCompare);
tracksForMenu.insert(0, TextTrack::captionMenuOffItem());
tracksForMenu.insert(1, TextTrack::captionMenuAutomaticItem());
......
......@@ -25,7 +25,6 @@
#include "TextureMapperImageBuffer.h"
#include "Timer.h"
#include <wtf/CurrentTime.h>
#include <wtf/NonCopyingSort.h>
#if USE(ACCELERATED_COMPOSITING) && USE(TEXTURE_MAPPER)
......@@ -85,7 +84,7 @@ void BitmapTexturePool::releaseUnusedTexturesTimerFired(Timer<BitmapTexturePool>
return;
// Delete entries, which have been unused in s_releaseUnusedSecondsTolerance.
nonCopyingSort(m_textures.begin(), m_textures.end(), BitmapTexturePoolEntry::compareTimeLastUsed);
std::sort(m_textures.begin(), m_textures.end(), BitmapTexturePoolEntry::compareTimeLastUsed);
double minUsedTime = monotonicallyIncreasingTime() - s_releaseUnusedSecondsTolerance;
for (size_t i = 0; i < m_textures.size(); ++i) {
......
2013-09-07 Anders Carlsson <andersca@apple.com>
Remove NonCopyableSort.h from WTF
https://bugs.webkit.org/show_bug.cgi?id=120984
Reviewed by Andreas Kling.
* WebKitSupport/RenderQueue.cpp:
(BlackBerry::WebKit::RenderQueue::quickSort):
2013-09-06 Ryosuke Niwa <rniwa@webkit.org>
Range::ownerDocument should return Document&
......
......@@ -24,8 +24,6 @@
#include "WebPageClient.h"
#include "WebPage_p.h"
#include <wtf/NonCopyingSort.h>
#define DEBUG_RENDER_QUEUE 0
#define DEBUG_RENDER_QUEUE_SORT 0
......@@ -378,7 +376,7 @@ void RenderQueue::quickSort(TileIndexList* queue)
if (!length)
return;
WTF::nonCopyingSort(queue->begin(), queue->end(), TileIndexLessThan(m_primarySortDirection, m_secondarySortDirection));
std::sort(queue->begin(), queue->end(), TileIndexLessThan(m_primarySortDirection, m_secondarySortDirection));
}
void RenderQueue::updateSortDirection(int lastDeltaX, int lastDeltaY)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment