haikuwebkit/Source/WTF/wtf/StdUnorderedSet.h

39 lines
1.6 KiB
C
Raw Permalink Normal View History

[WTF] Add standard containers with FastAllocator specialization https://bugs.webkit.org/show_bug.cgi?id=183789 Reviewed by Darin Adler. Source/JavaScriptCore: * b3/air/testair.cpp: * b3/testb3.cpp: (JSC::B3::testDoubleLiteralComparison): (JSC::B3::testFloatEqualOrUnorderedFoldingNaN): * dfg/DFGGraph.h: * dfg/DFGIntegerCheckCombiningPhase.cpp: * dfg/DFGObjectAllocationSinkingPhase.cpp: * ftl/FTLLowerDFGToB3.cpp: (JSC::FTL::DFG::LowerDFGToB3::switchStringSlow): * runtime/FunctionHasExecutedCache.h: * runtime/TypeLocationCache.h: Source/WebCore: * Modules/indexeddb/IDBKeyData.h: * Modules/mediasource/SampleMap.h: * Modules/mediasource/SourceBuffer.cpp: * Modules/webauthn/cbor/CBORValue.h: It did not use FastAllocator for its container. * page/WheelEventTestTrigger.h: * platform/audio/PlatformMediaSessionManager.h: * platform/graphics/avfoundation/objc/ImageDecoderAVFObjC.h: * platform/graphics/avfoundation/objc/ImageDecoderAVFObjC.mm: * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm: * platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm: * platform/graphics/cv/VideoTextureCopierCV.cpp: (WebCore::YCbCrToRGBMatrixForRangeAndTransferFunction): * platform/mock/mediasource/MockSourceBufferPrivate.cpp: * platform/wpe/PlatformPasteboardWPE.cpp: * rendering/OrderIterator.h: Source/WTF: Sometimes we want standard containers due to various reasons. For example, WTF::HashMap lacks the ability to hold all the integer keys since it uses 0 for empty value and -1 for deleted value. However, using std::containers use std::allocator without specialization. This patch introduces WTF::{StdMap, StdSet, StdList, StdUnorderedMap, StdUnorderedSet}. They are standard containers with FastAllocator specialization. * WTF.xcodeproj/project.pbxproj: * wtf/CMakeLists.txt: * wtf/StdList.h: Copied from Source/JavaScriptCore/runtime/TypeLocationCache.h. * wtf/StdMap.h: Copied from Source/JavaScriptCore/runtime/TypeLocationCache.h. * wtf/StdSet.h: Copied from Source/JavaScriptCore/runtime/TypeLocationCache.h. * wtf/StdUnorderedMap.h: Copied from Source/JavaScriptCore/runtime/TypeLocationCache.h. * wtf/StdUnorderedSet.h: Copied from Source/JavaScriptCore/runtime/TypeLocationCache.h. Canonical link: https://commits.webkit.org/199528@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@229893 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-03-23 12:34:08 +00:00
/*
* Copyright (C) 2018 Yusuke Suzuki <utatane.tea@gmail.com>.
*
* 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 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 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.
*/
#pragma once
#include <unordered_set>
#include <wtf/FastMalloc.h>
namespace WTF {
template<typename Key, typename Hash = std::hash<Key>, typename Predicate = std::equal_to<Key>, typename Allocator = FastAllocator<Key>>
using StdUnorderedSet = std::unordered_set<Key, Hash, Predicate, Allocator>;
} // namespace WTF
using WTF::StdUnorderedSet;