Title: [219702] trunk/Source
Revision
219702
Author
[email protected]
Date
2017-07-20 14:06:12 -0700 (Thu, 20 Jul 2017)

Log Message

Replace calls to Vector::resize() with calls to more efficient shrink() / grow() when applicable
https://bugs.webkit.org/show_bug.cgi?id=174660

Reviewed by Geoffrey Garen.

Replace calls to Vector::resize() with calls to more efficient shrink() / grow() when applicable.
This essentially replaces a branch to figure out if the new size is less or greater than the
current size by an assertion.

Source/bmalloc:

* bmalloc/Map.h:
(bmalloc::Hash>::rehash):

Source/_javascript_Core:

* b3/B3BasicBlockUtils.h:
(JSC::B3::clearPredecessors):
* b3/B3InferSwitches.cpp:
* b3/B3LowerToAir.cpp:
(JSC::B3::Air::LowerToAir::finishAppendingInstructions):
* b3/B3ReduceStrength.cpp:
* b3/B3SparseCollection.h:
(JSC::B3::SparseCollection::packIndices):
* b3/B3UseCounts.cpp:
(JSC::B3::UseCounts::UseCounts):
* b3/air/AirAllocateRegistersAndStackByLinearScan.cpp:
* b3/air/AirEmitShuffle.cpp:
(JSC::B3::Air::emitShuffle):
* b3/air/AirLowerAfterRegAlloc.cpp:
(JSC::B3::Air::lowerAfterRegAlloc):
* b3/air/AirOptimizeBlockOrder.cpp:
(JSC::B3::Air::optimizeBlockOrder):
* bytecode/Operands.h:
(JSC::Operands::ensureLocals):
* bytecode/PreciseJumpTargets.cpp:
(JSC::computePreciseJumpTargetsInternal):
* dfg/DFGBlockInsertionSet.cpp:
(JSC::DFG::BlockInsertionSet::execute):
* dfg/DFGBlockMapInlines.h:
(JSC::DFG::BlockMap<T>::BlockMap):
* dfg/DFGByteCodeParser.cpp:
(JSC::DFG::ByteCodeParser::processSetLocalQueue):
(JSC::DFG::ByteCodeParser::clearCaches):
* dfg/DFGDisassembler.cpp:
(JSC::DFG::Disassembler::Disassembler):
* dfg/DFGFlowIndexing.cpp:
(JSC::DFG::FlowIndexing::recompute):
* dfg/DFGGraph.cpp:
(JSC::DFG::Graph::registerFrozenValues):
* dfg/DFGInPlaceAbstractState.cpp:
(JSC::DFG::setLiveValues):
* dfg/DFGLICMPhase.cpp:
(JSC::DFG::LICMPhase::run):
* dfg/DFGLivenessAnalysisPhase.cpp:
* dfg/DFGNaturalLoops.cpp:
(JSC::DFG::NaturalLoops::NaturalLoops):
* dfg/DFGStoreBarrierClusteringPhase.cpp:
* ftl/FTLLowerDFGToB3.cpp:
(JSC::FTL::DFG::LowerDFGToB3::compileNode):
* heap/CodeBlockSet.cpp:
(JSC::CodeBlockSet::deleteUnmarkedAndUnreferenced):
* heap/MarkedSpace.cpp:
(JSC::MarkedSpace::sweepLargeAllocations):
* inspector/ContentSearchUtilities.cpp:
(Inspector::ContentSearchUtilities::findMagicComment):
* interpreter/ShadowChicken.cpp:
(JSC::ShadowChicken::update):
* parser/ASTBuilder.h:
(JSC::ASTBuilder::shrinkOperandStackBy):
* parser/Lexer.h:
(JSC::Lexer::setOffset):
* runtime/RegExpInlines.h:
(JSC::RegExp::matchInline):
* runtime/RegExpPrototype.cpp:
(JSC::genericSplit):
* yarr/RegularExpression.cpp:
(JSC::Yarr::RegularExpression::match):

Source/WebCore:

* Modules/gamepad/Gamepad.cpp:
(WebCore::Gamepad::Gamepad):
* Modules/webaudio/AudioContext.cpp:
(WebCore::AudioContext::addReaction):
* Modules/websockets/WebSocketChannel.cpp:
(WebCore::WebSocketChannel::skipBuffer):
* Modules/websockets/WebSocketDeflater.cpp:
(WebCore::WebSocketDeflater::finish):
* contentextensions/ContentExtensionCompiler.cpp:
(WebCore::ContentExtensions::serializeSelector):
* contentextensions/DFABytecodeCompiler.cpp:
(WebCore::ContentExtensions::append):
* crypto/gcrypt/CryptoAlgorithmAES_CBCGCrypt.cpp:
(WebCore::gcryptEncrypt):
(WebCore::gcryptDecrypt):
* crypto/gcrypt/CryptoAlgorithmECDHGCrypt.cpp:
(WebCore::gcryptDerive):
* platform/gamepad/cocoa/GameControllerGamepadProvider.mm:
(WebCore::GameControllerGamepadProvider::controllerDidConnect):
* platform/gamepad/mac/HIDGamepadProvider.cpp:
(WebCore::HIDGamepadProvider::deviceAdded):
* platform/graphics/ImageBackingStore.h:
(WebCore::ImageBackingStore::setSize):
* platform/graphics/WOFFFileFormat.cpp:
* platform/graphics/avfoundation/InbandMetadataTextTrackPrivateAVF.cpp:
(WebCore::InbandMetadataTextTrackPrivateAVF::updatePendingCueEndTimes):
(WebCore::InbandMetadataTextTrackPrivateAVF::flushPartialCues):
* platform/graphics/avfoundation/InbandTextTrackPrivateAVF.cpp:
(WebCore::InbandTextTrackPrivateAVF::resetCueValues):
(WebCore::InbandTextTrackPrivateAVF::readNativeSampleBuffer):
* platform/graphics/avfoundation/cf/InbandTextTrackPrivateAVCF.cpp:
(WebCore::InbandTextTrackPrivateAVCF::readNativeSampleBuffer):
* platform/graphics/cg/ImageBufferCG.cpp:
(WebCore::cfData):
* platform/image-decoders/bmp/BMPImageDecoder.cpp:
(WebCore::BMPImageDecoder::frameBufferAtIndex):
* platform/image-decoders/ico/ICOImageDecoder.cpp:
(WebCore::ICOImageDecoder::decode):
* platform/image-decoders/jpeg/JPEGImageDecoder.cpp:
(WebCore::JPEGImageDecoder::frameBufferAtIndex):
* platform/image-decoders/png/PNGImageDecoder.cpp:
(WebCore::PNGImageDecoder::frameBufferAtIndex):
(WebCore::PNGImageDecoder::readChunks):
* platform/image-decoders/webp/WEBPImageDecoder.cpp:
(WebCore::WEBPImageDecoder::frameBufferAtIndex):
* platform/image-encoders/JPEGImageEncoder.cpp:
(WebCore::compressRGBABigEndianToJPEG):
* platform/text/DecodeEscapeSequences.h:
(WebCore::URLEscapeSequence::decodeRun):
* platform/text/SuffixTree.h:
(WebCore::SuffixTree::Node::Node):
* rendering/Grid.cpp:
(WebCore::Grid::setNeedsItemsPlacement):
* rendering/RenderTable.cpp:
(WebCore::RenderTable::invalidateCachedColumns):

Source/WebKit:

* Platform/IPC/ArgumentCoders.h:
* UIProcess/Gamepad/UIGamepadProvider.cpp:
(WebKit::UIGamepadProvider::platformGamepadConnected):
* UIProcess/WebProcessPool.cpp:
(WebKit::WebProcessPool::setInitialConnectedGamepads):
* WebProcess/Network/WebLoaderStrategy.cpp:
(WebKit::WebLoaderStrategy::loadResourceSynchronously):
* WebProcess/WebCoreSupport/WebPasteboardOverrides.cpp:
(WebKit::WebPasteboardOverrides::getDataForOverride):
* WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::WebPage::requestAutocorrectionData):

Source/WebKitLegacy/mac:

* Plugins/WebNetscapePluginView.mm:
(-[WebNetscapePluginView saveAndSetNewPortStateForUpdate:]):

Source/WTF:

* wtf/IndexSparseSet.h:
(WTF::OverflowHandler>::IndexSparseSet):
(WTF::OverflowHandler>::clear):
* wtf/Insertion.h:
(WTF::executeInsertions):
* wtf/RangeSet.h:
(WTF::RangeSet::compact):
* wtf/Vector.h:
(WTF::removeRepeatedElements):
* wtf/persistence/Coders.h:

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (219701 => 219702)


--- trunk/Source/_javascript_Core/ChangeLog	2017-07-20 20:52:22 UTC (rev 219701)
+++ trunk/Source/_javascript_Core/ChangeLog	2017-07-20 21:06:12 UTC (rev 219702)
@@ -1,3 +1,77 @@
+2017-07-20  Chris Dumez  <[email protected]>
+
+        Replace calls to Vector::resize() with calls to more efficient shrink() / grow() when applicable
+        https://bugs.webkit.org/show_bug.cgi?id=174660
+
+        Reviewed by Geoffrey Garen.
+
+        Replace calls to Vector::resize() with calls to more efficient shrink() / grow() when applicable.
+        This essentially replaces a branch to figure out if the new size is less or greater than the
+        current size by an assertion.
+
+        * b3/B3BasicBlockUtils.h:
+        (JSC::B3::clearPredecessors):
+        * b3/B3InferSwitches.cpp:
+        * b3/B3LowerToAir.cpp:
+        (JSC::B3::Air::LowerToAir::finishAppendingInstructions):
+        * b3/B3ReduceStrength.cpp:
+        * b3/B3SparseCollection.h:
+        (JSC::B3::SparseCollection::packIndices):
+        * b3/B3UseCounts.cpp:
+        (JSC::B3::UseCounts::UseCounts):
+        * b3/air/AirAllocateRegistersAndStackByLinearScan.cpp:
+        * b3/air/AirEmitShuffle.cpp:
+        (JSC::B3::Air::emitShuffle):
+        * b3/air/AirLowerAfterRegAlloc.cpp:
+        (JSC::B3::Air::lowerAfterRegAlloc):
+        * b3/air/AirOptimizeBlockOrder.cpp:
+        (JSC::B3::Air::optimizeBlockOrder):
+        * bytecode/Operands.h:
+        (JSC::Operands::ensureLocals):
+        * bytecode/PreciseJumpTargets.cpp:
+        (JSC::computePreciseJumpTargetsInternal):
+        * dfg/DFGBlockInsertionSet.cpp:
+        (JSC::DFG::BlockInsertionSet::execute):
+        * dfg/DFGBlockMapInlines.h:
+        (JSC::DFG::BlockMap<T>::BlockMap):
+        * dfg/DFGByteCodeParser.cpp:
+        (JSC::DFG::ByteCodeParser::processSetLocalQueue):
+        (JSC::DFG::ByteCodeParser::clearCaches):
+        * dfg/DFGDisassembler.cpp:
+        (JSC::DFG::Disassembler::Disassembler):
+        * dfg/DFGFlowIndexing.cpp:
+        (JSC::DFG::FlowIndexing::recompute):
+        * dfg/DFGGraph.cpp:
+        (JSC::DFG::Graph::registerFrozenValues):
+        * dfg/DFGInPlaceAbstractState.cpp:
+        (JSC::DFG::setLiveValues):
+        * dfg/DFGLICMPhase.cpp:
+        (JSC::DFG::LICMPhase::run):
+        * dfg/DFGLivenessAnalysisPhase.cpp:
+        * dfg/DFGNaturalLoops.cpp:
+        (JSC::DFG::NaturalLoops::NaturalLoops):
+        * dfg/DFGStoreBarrierClusteringPhase.cpp:
+        * ftl/FTLLowerDFGToB3.cpp:
+        (JSC::FTL::DFG::LowerDFGToB3::compileNode):
+        * heap/CodeBlockSet.cpp:
+        (JSC::CodeBlockSet::deleteUnmarkedAndUnreferenced):
+        * heap/MarkedSpace.cpp:
+        (JSC::MarkedSpace::sweepLargeAllocations):
+        * inspector/ContentSearchUtilities.cpp:
+        (Inspector::ContentSearchUtilities::findMagicComment):
+        * interpreter/ShadowChicken.cpp:
+        (JSC::ShadowChicken::update):
+        * parser/ASTBuilder.h:
+        (JSC::ASTBuilder::shrinkOperandStackBy):
+        * parser/Lexer.h:
+        (JSC::Lexer::setOffset):
+        * runtime/RegExpInlines.h:
+        (JSC::RegExp::matchInline):
+        * runtime/RegExpPrototype.cpp:
+        (JSC::genericSplit):
+        * yarr/RegularExpression.cpp:
+        (JSC::Yarr::RegularExpression::match):
+
 2017-07-20  Yusuke Suzuki  <[email protected]>
 
         [WTF] Use ThreadGroup to bookkeep active threads for Mach exception

Modified: trunk/Source/_javascript_Core/b3/B3BasicBlockUtils.h (219701 => 219702)


--- trunk/Source/_javascript_Core/b3/B3BasicBlockUtils.h	2017-07-20 20:52:22 UTC (rev 219701)
+++ trunk/Source/_javascript_Core/b3/B3BasicBlockUtils.h	2017-07-20 21:06:12 UTC (rev 219702)
@@ -89,7 +89,7 @@
 {
     for (auto& block : blocks) {
         if (block)
-            block->predecessors().resize(0);
+            block->predecessors().shrink(0);
     }
 }
 

Modified: trunk/Source/_javascript_Core/b3/B3InferSwitches.cpp (219701 => 219702)


--- trunk/Source/_javascript_Core/b3/B3InferSwitches.cpp	2017-07-20 20:52:22 UTC (rev 219701)
+++ trunk/Source/_javascript_Core/b3/B3InferSwitches.cpp	2017-07-20 21:06:12 UTC (rev 219702)
@@ -195,7 +195,7 @@
                 m_insertionSet.insertValue(predecessor->size() - 1, value);
         }
         m_insertionSet.execute(predecessor);
-        block->values().resize(0);
+        block->values().shrink(0);
         block->appendNew<Value>(m_proc, Oops, description.branch->origin());
         block->removePredecessor(predecessor);
         

Modified: trunk/Source/_javascript_Core/b3/B3LowerToAir.cpp (219701 => 219702)


--- trunk/Source/_javascript_Core/b3/B3LowerToAir.cpp	2017-07-20 20:52:22 UTC (rev 219701)
+++ trunk/Source/_javascript_Core/b3/B3LowerToAir.cpp	2017-07-20 21:06:12 UTC (rev 219702)
@@ -1184,7 +1184,7 @@
             for (Inst& inst : m_insts[i])
                 target->appendInst(WTFMove(inst));
         }
-        m_insts.resize(0);
+        m_insts.shrink(0);
     }
     
     Air::BasicBlock* newBlock()

Modified: trunk/Source/_javascript_Core/b3/B3ReduceStrength.cpp (219701 => 219702)


--- trunk/Source/_javascript_Core/b3/B3ReduceStrength.cpp	2017-07-20 20:52:22 UTC (rev 219701)
+++ trunk/Source/_javascript_Core/b3/B3ReduceStrength.cpp	2017-07-20 21:06:12 UTC (rev 219702)
@@ -2370,7 +2370,7 @@
                     
                     // Make sure that the successor has nothing left in it. Make sure that the block
                     // has a terminal so that nobody chokes when they look at it.
-                    successor->values().resize(0);
+                    successor->values().shrink(0);
                     successor->appendNew<Value>(m_proc, Oops, jumpOrigin);
                     successor->clearSuccessors();
                     

Modified: trunk/Source/_javascript_Core/b3/B3SparseCollection.h (219701 => 219702)


--- trunk/Source/_javascript_Core/b3/B3SparseCollection.h	2017-07-20 20:52:22 UTC (rev 219701)
+++ trunk/Source/_javascript_Core/b3/B3SparseCollection.h	2017-07-20 21:06:12 UTC (rev 219702)
@@ -107,8 +107,8 @@
             ++holeIndex;
         }
 
-        m_indexFreeList.resize(0);
-        m_vector.resize(endIndex);
+        m_indexFreeList.shrink(0);
+        m_vector.shrink(endIndex);
     }
 
     unsigned size() const { return m_vector.size(); }

Modified: trunk/Source/_javascript_Core/b3/B3UseCounts.cpp (219701 => 219702)


--- trunk/Source/_javascript_Core/b3/B3UseCounts.cpp	2017-07-20 20:52:22 UTC (rev 219701)
+++ trunk/Source/_javascript_Core/b3/B3UseCounts.cpp	2017-07-20 21:06:12 UTC (rev 219702)
@@ -37,7 +37,7 @@
 {
     Vector<Value*, 64> children;
     for (Value* value : procedure.values()) {
-        children.resize(0);
+        children.shrink(0);
         for (Value* child : value->children()) {
             m_counts[child].numUses++;
             children.append(child);

Modified: trunk/Source/_javascript_Core/b3/air/AirAllocateRegistersAndStackByLinearScan.cpp (219701 => 219702)


--- trunk/Source/_javascript_Core/b3/air/AirAllocateRegistersAndStackByLinearScan.cpp	2017-07-20 20:52:22 UTC (rev 219701)
+++ trunk/Source/_javascript_Core/b3/air/AirAllocateRegistersAndStackByLinearScan.cpp	2017-07-20 21:06:12 UTC (rev 219702)
@@ -333,7 +333,7 @@
     template<typename SelectFunc>
     void prepareIntervals(const SelectFunc& selectFunc)
     {
-        m_tmps.resize(0);
+        m_tmps.shrink(0);
         
         m_code.forEachTmp(
             [&] (Tmp tmp) {

Modified: trunk/Source/_javascript_Core/b3/air/AirEmitShuffle.cpp (219701 => 219702)


--- trunk/Source/_javascript_Core/b3/air/AirEmitShuffle.cpp	2017-07-20 20:52:22 UTC (rev 219701)
+++ trunk/Source/_javascript_Core/b3/air/AirEmitShuffle.cpp	2017-07-20 21:06:12 UTC (rev 219702)
@@ -275,7 +275,7 @@
                 for (unsigned i = rotate.loop.size() - 1; i--;)
                     ASSERT(rotate.loop[i].dst() == rotate.loop[i + 1].src());
                 rotates.append(WTFMove(rotate));
-                currentPairs.resize(0);
+                currentPairs.shrink(0);
             } else {
                 if (verbose)
                     dataLog("It's a shift.\n");

Modified: trunk/Source/_javascript_Core/b3/air/AirLowerAfterRegAlloc.cpp (219701 => 219702)


--- trunk/Source/_javascript_Core/b3/air/AirLowerAfterRegAlloc.cpp	2017-07-20 20:52:22 UTC (rev 219701)
+++ trunk/Source/_javascript_Core/b3/air/AirLowerAfterRegAlloc.cpp	2017-07-20 21:06:12 UTC (rev 219702)
@@ -232,7 +232,7 @@
                     inst.kind.effects = true;
 
                 // Now we need to emit code to restore registers.
-                pairs.resize(0);
+                pairs.shrink(0);
                 unsigned stackSlotIndex = 0;
                 regsToSave.forEach(
                     [&] (Reg reg) {

Modified: trunk/Source/_javascript_Core/b3/air/AirOptimizeBlockOrder.cpp (219701 => 219702)


--- trunk/Source/_javascript_Core/b3/air/AirOptimizeBlockOrder.cpp	2017-07-20 20:52:22 UTC (rev 219701)
+++ trunk/Source/_javascript_Core/b3/air/AirOptimizeBlockOrder.cpp	2017-07-20 21:06:12 UTC (rev 219702)
@@ -64,7 +64,7 @@
         for (unsigned i = 0; i < m_successors.size(); ++i)
             worklist.push(m_successors[i]);
         
-        m_successors.resize(0);
+        m_successors.shrink(0);
     }
 
 private:
@@ -137,7 +137,7 @@
     for (auto& entry : code.blockList())
         entry.release();
 
-    code.blockList().resize(0);
+    code.blockList().shrink(0);
 
     for (unsigned i = 0; i < blocksInOrder.size(); ++i) {
         BasicBlock* block = blocksInOrder[i];

Modified: trunk/Source/_javascript_Core/bytecode/Operands.h (219701 => 219702)


--- trunk/Source/_javascript_Core/bytecode/Operands.h	2017-07-20 20:52:22 UTC (rev 219701)
+++ trunk/Source/_javascript_Core/bytecode/Operands.h	2017-07-20 21:06:12 UTC (rev 219702)
@@ -101,11 +101,11 @@
     
     void ensureLocals(size_t size)
     {
-        if (size <= m_locals.size())
+        size_t oldSize = m_locals.size();
+        if (size <= oldSize)
             return;
 
-        size_t oldSize = m_locals.size();
-        m_locals.resize(size);
+        m_locals.grow(size);
         if (!WTF::VectorTraits<T>::needsInitialization) {
             for (size_t i = oldSize; i < m_locals.size(); ++i)
                 m_locals[i] = T();
@@ -114,11 +114,11 @@
 
     void ensureLocals(size_t size, const T& ensuredValue)
     {
-        if (size <= m_locals.size())
+        size_t oldSize = m_locals.size();
+        if (size <= oldSize)
             return;
 
-        size_t oldSize = m_locals.size();
-        m_locals.resize(size);
+        m_locals.grow(size);
         for (size_t i = oldSize; i < m_locals.size(); ++i)
             m_locals[i] = ensuredValue;
     }

Modified: trunk/Source/_javascript_Core/bytecode/PreciseJumpTargets.cpp (219701 => 219702)


--- trunk/Source/_javascript_Core/bytecode/PreciseJumpTargets.cpp	2017-07-20 20:52:22 UTC (rev 219701)
+++ trunk/Source/_javascript_Core/bytecode/PreciseJumpTargets.cpp	2017-07-20 21:06:12 UTC (rev 219702)
@@ -84,8 +84,7 @@
         out[toIndex++] = value;
         lastValue = value;
     }
-    out.resize(toIndex);
-    out.shrinkToFit();
+    out.shrinkCapacity(toIndex);
 }
 
 void computePreciseJumpTargets(CodeBlock* codeBlock, Vector<unsigned, 32>& out)

Modified: trunk/Source/_javascript_Core/dfg/DFGBlockInsertionSet.cpp (219701 => 219702)


--- trunk/Source/_javascript_Core/dfg/DFGBlockInsertionSet.cpp	2017-07-20 20:52:22 UTC (rev 219701)
+++ trunk/Source/_javascript_Core/dfg/DFGBlockInsertionSet.cpp	2017-07-20 21:06:12 UTC (rev 219702)
@@ -88,7 +88,7 @@
             continue;
         m_graph.m_blocks[targetIndex++] = block;
     }
-    m_graph.m_blocks.resize(targetIndex);
+    m_graph.m_blocks.shrink(targetIndex);
     
     // Make sure that the blocks know their new indices.
     for (unsigned i = 0; i < m_graph.m_blocks.size(); ++i)

Modified: trunk/Source/_javascript_Core/dfg/DFGBlockMapInlines.h (219701 => 219702)


--- trunk/Source/_javascript_Core/dfg/DFGBlockMapInlines.h	2017-07-20 20:52:22 UTC (rev 219701)
+++ trunk/Source/_javascript_Core/dfg/DFGBlockMapInlines.h	2017-07-20 21:06:12 UTC (rev 219702)
@@ -35,7 +35,7 @@
 template<typename T>
 BlockMap<T>::BlockMap(Graph& graph)
 {
-    m_vector.resize(graph.numBlocks());
+    m_vector.grow(graph.numBlocks());
 }
 
 } } // namespace JSC::DFG

Modified: trunk/Source/_javascript_Core/dfg/DFGByteCodeParser.cpp (219701 => 219702)


--- trunk/Source/_javascript_Core/dfg/DFGByteCodeParser.cpp	2017-07-20 20:52:22 UTC (rev 219701)
+++ trunk/Source/_javascript_Core/dfg/DFGByteCodeParser.cpp	2017-07-20 21:06:12 UTC (rev 219702)
@@ -414,7 +414,7 @@
     {
         for (unsigned i = 0; i < m_setLocalQueue.size(); ++i)
             m_setLocalQueue[i].execute(this);
-        m_setLocalQueue.resize(0);
+        m_setLocalQueue.shrink(0);
     }
 
     Node* set(VirtualRegister operand, Node* value, SetMode setMode = NormalSet)
@@ -4055,7 +4055,7 @@
 
 void ByteCodeParser::clearCaches()
 {
-    m_constants.resize(0);
+    m_constants.shrink(0);
 }
 
 bool ByteCodeParser::parseBlock(unsigned limit)

Modified: trunk/Source/_javascript_Core/dfg/DFGDisassembler.cpp (219701 => 219702)


--- trunk/Source/_javascript_Core/dfg/DFGDisassembler.cpp	2017-07-20 20:52:22 UTC (rev 219701)
+++ trunk/Source/_javascript_Core/dfg/DFGDisassembler.cpp	2017-07-20 21:06:12 UTC (rev 219702)
@@ -43,7 +43,7 @@
     : m_graph(graph)
 {
     m_dumpContext.graph = &m_graph;
-    m_labelForBlockIndex.resize(graph.numBlocks());
+    m_labelForBlockIndex.grow(graph.numBlocks());
 }
 
 void Disassembler::dump(PrintStream& out, LinkBuffer& linkBuffer)

Modified: trunk/Source/_javascript_Core/dfg/DFGFlowIndexing.cpp (219701 => 219702)


--- trunk/Source/_javascript_Core/dfg/DFGFlowIndexing.cpp	2017-07-20 20:52:22 UTC (rev 219701)
+++ trunk/Source/_javascript_Core/dfg/DFGFlowIndexing.cpp	2017-07-20 21:06:12 UTC (rev 219702)
@@ -48,7 +48,7 @@
     m_nodeIndexToShadowIndex.resize(numNodeIndices);
     m_nodeIndexToShadowIndex.fill(UINT_MAX);
     
-    m_shadowIndexToNodeIndex.resize(0);
+    m_shadowIndexToNodeIndex.shrink(0);
 
     m_numIndices = numNodeIndices;
 

Modified: trunk/Source/_javascript_Core/dfg/DFGGraph.cpp (219701 => 219702)


--- trunk/Source/_javascript_Core/dfg/DFGGraph.cpp	2017-07-20 20:52:22 UTC (rev 219701)
+++ trunk/Source/_javascript_Core/dfg/DFGGraph.cpp	2017-07-20 21:06:12 UTC (rev 219702)
@@ -1330,7 +1330,7 @@
 
 void Graph::registerFrozenValues()
 {
-    m_codeBlock->constants().resize(0);
+    m_codeBlock->constants().shrink(0);
     m_codeBlock->constantsSourceCodeRepresentation().resize(0);
     for (FrozenValue* value : m_frozenValues) {
         if (!value->pointsToHeap())

Modified: trunk/Source/_javascript_Core/dfg/DFGInPlaceAbstractState.cpp (219701 => 219702)


--- trunk/Source/_javascript_Core/dfg/DFGInPlaceAbstractState.cpp	2017-07-20 20:52:22 UTC (rev 219701)
+++ trunk/Source/_javascript_Core/dfg/DFGInPlaceAbstractState.cpp	2017-07-20 21:06:12 UTC (rev 219702)
@@ -85,7 +85,7 @@
 
 static void setLiveValues(Vector<NodeAbstractValuePair>& values, const Vector<NodeFlowProjection>& live)
 {
-    values.resize(0);
+    values.shrink(0);
     values.reserveCapacity(live.size());
     for (NodeFlowProjection node : live)
         values.uncheckedAppend(NodeAbstractValuePair { node, AbstractValue() });

Modified: trunk/Source/_javascript_Core/dfg/DFGLICMPhase.cpp (219701 => 219702)


--- trunk/Source/_javascript_Core/dfg/DFGLICMPhase.cpp	2017-07-20 20:52:22 UTC (rev 219701)
+++ trunk/Source/_javascript_Core/dfg/DFGLICMPhase.cpp	2017-07-20 21:06:12 UTC (rev 219702)
@@ -195,7 +195,7 @@
             if (!loop)
                 continue;
             
-            loopStack.resize(0);
+            loopStack.shrink(0);
             for (
                 const NaturalLoop* current = loop;
                 current;

Modified: trunk/Source/_javascript_Core/dfg/DFGLivenessAnalysisPhase.cpp (219701 => 219702)


--- trunk/Source/_javascript_Core/dfg/DFGLivenessAnalysisPhase.cpp	2017-07-20 20:52:22 UTC (rev 219701)
+++ trunk/Source/_javascript_Core/dfg/DFGLivenessAnalysisPhase.cpp	2017-07-20 21:06:12 UTC (rev 219702)
@@ -96,7 +96,7 @@
             {
                 const Vector<unsigned, 0, UnsafeVectorOverflow, 1>& liveAtHeadIndices = m_liveAtHead[blockIndex];
                 Vector<NodeFlowProjection>& liveAtHead = block->ssa->liveAtHead;
-                liveAtHead.resize(0);
+                liveAtHead.shrink(0);
                 liveAtHead.reserveCapacity(liveAtHeadIndices.size());
                 for (unsigned index : liveAtHeadIndices)
                     liveAtHead.uncheckedAppend(m_indexing.nodeProjection(index));
@@ -104,7 +104,7 @@
             {
                 const LiveSet& liveAtTailIndices = m_liveAtTail[blockIndex];
                 Vector<NodeFlowProjection>& liveAtTail = block->ssa->liveAtTail;
-                liveAtTail.resize(0);
+                liveAtTail.shrink(0);
                 liveAtTail.reserveCapacity(liveAtTailIndices.size());
                 for (unsigned index : m_liveAtTail[blockIndex])
                     liveAtTail.uncheckedAppend(m_indexing.nodeProjection(index));

Modified: trunk/Source/_javascript_Core/dfg/DFGNaturalLoops.cpp (219701 => 219702)


--- trunk/Source/_javascript_Core/dfg/DFGNaturalLoops.cpp	2017-07-20 20:52:22 UTC (rev 219701)
+++ trunk/Source/_javascript_Core/dfg/DFGNaturalLoops.cpp	2017-07-20 21:06:12 UTC (rev 219702)
@@ -62,7 +62,7 @@
         graph.m_dominators->dump(WTF::dataFile());
     }
     
-    m_loops.resize(0);
+    m_loops.shrink(0);
     
     for (BlockIndex blockIndex = graph.numBlocks(); blockIndex--;) {
         BasicBlock* block = graph.block(blockIndex);

Modified: trunk/Source/_javascript_Core/dfg/DFGStoreBarrierClusteringPhase.cpp (219701 => 219702)


--- trunk/Source/_javascript_Core/dfg/DFGStoreBarrierClusteringPhase.cpp	2017-07-20 20:52:22 UTC (rev 219701)
+++ trunk/Source/_javascript_Core/dfg/DFGStoreBarrierClusteringPhase.cpp	2017-07-20 21:06:12 UTC (rev 219702)
@@ -149,7 +149,7 @@
                     nodeIndex, SpecNone, type, origin.withSemantic(semanticOrigin),
                     Edge(child, KnownCellUse));
             }
-            m_neededBarriers.resize(0);
+            m_neededBarriers.shrink(0);
         }
         
         m_insertionSet.execute(block);

Modified: trunk/Source/_javascript_Core/ftl/FTLLowerDFGToB3.cpp (219701 => 219702)


--- trunk/Source/_javascript_Core/ftl/FTLLowerDFGToB3.cpp	2017-07-20 20:52:22 UTC (rev 219701)
+++ trunk/Source/_javascript_Core/ftl/FTLLowerDFGToB3.cpp	2017-07-20 21:06:12 UTC (rev 219702)
@@ -464,7 +464,7 @@
         if (verboseCompilationEnabled())
             dataLog("Lowering ", m_node, "\n");
         
-        m_availableRecoveries.resize(0);
+        m_availableRecoveries.shrink(0);
         
         m_interpreter.startExecuting();
         m_interpreter.executeKnownEdgeTypes(m_node);

Modified: trunk/Source/_javascript_Core/heap/CodeBlockSet.cpp (219701 => 219702)


--- trunk/Source/_javascript_Core/heap/CodeBlockSet.cpp	2017-07-20 20:52:22 UTC (rev 219701)
+++ trunk/Source/_javascript_Core/heap/CodeBlockSet.cpp	2017-07-20 21:06:12 UTC (rev 219702)
@@ -86,7 +86,7 @@
             codeBlock->structure(vm)->classInfo()->methodTable.destroy(codeBlock);
             set.remove(codeBlock);
         }
-        unmarked.resize(0);
+        unmarked.shrink(0);
     };
 
     switch (scope) {

Modified: trunk/Source/_javascript_Core/heap/MarkedSpace.cpp (219701 => 219702)


--- trunk/Source/_javascript_Core/heap/MarkedSpace.cpp	2017-07-20 20:52:22 UTC (rev 219701)
+++ trunk/Source/_javascript_Core/heap/MarkedSpace.cpp	2017-07-20 21:06:12 UTC (rev 219702)
@@ -248,7 +248,7 @@
         }
         m_largeAllocations[dstIndex++] = allocation;
     }
-    m_largeAllocations.resize(dstIndex);
+    m_largeAllocations.shrink(dstIndex);
     m_largeAllocationsNurseryOffset = m_largeAllocations.size();
 }
 

Modified: trunk/Source/_javascript_Core/inspector/ContentSearchUtilities.cpp (219701 => 219702)


--- trunk/Source/_javascript_Core/inspector/ContentSearchUtilities.cpp	2017-07-20 20:52:22 UTC (rev 219701)
+++ trunk/Source/_javascript_Core/inspector/ContentSearchUtilities.cpp	2017-07-20 21:06:12 UTC (rev 219702)
@@ -186,7 +186,7 @@
 
     ASSERT(pattern.m_numSubpatterns == 1);
     Vector<int, 4> matches;
-    matches.resize(4);
+    matches.grow(4);
     unsigned result = JSC::Yarr::interpret(bytecodePattern.get(), content, 0, reinterpret_cast<unsigned*>(matches.data()));
     if (result == JSC::Yarr::offsetNoMatch)
         return String();

Modified: trunk/Source/_javascript_Core/interpreter/ShadowChicken.cpp (219701 => 219702)


--- trunk/Source/_javascript_Core/interpreter/ShadowChicken.cpp	2017-07-20 20:52:22 UTC (rev 219701)
+++ trunk/Source/_javascript_Core/interpreter/ShadowChicken.cpp	2017-07-20 21:06:12 UTC (rev 219702)
@@ -395,7 +395,7 @@
                 }
                 m_stack[dstIndex++] = frame;
             }
-            m_stack.resize(dstIndex);
+            m_stack.shrink(dstIndex);
         }
     }
 

Modified: trunk/Source/_javascript_Core/parser/ASTBuilder.h (219701 => 219702)


--- trunk/Source/_javascript_Core/parser/ASTBuilder.h	2017-07-20 20:52:22 UTC (rev 219701)
+++ trunk/Source/_javascript_Core/parser/ASTBuilder.h	2017-07-20 21:06:12 UTC (rev 219702)
@@ -854,7 +854,7 @@
     {
         operandStackDepth -= amount;
         ASSERT(operandStackDepth >= 0);
-        m_binaryOperandStack.resize(m_binaryOperandStack.size() - amount);
+        m_binaryOperandStack.shrink(m_binaryOperandStack.size() - amount);
     }
     void appendBinaryOperation(const JSTokenLocation& location, int& operandStackDepth, int&, const BinaryOperand& lhs, const BinaryOperand& rhs)
     {

Modified: trunk/Source/_javascript_Core/parser/Lexer.h (219701 => 219702)


--- trunk/Source/_javascript_Core/parser/Lexer.h	2017-07-20 20:52:22 UTC (rev 219701)
+++ trunk/Source/_javascript_Core/parser/Lexer.h	2017-07-20 21:06:12 UTC (rev 219702)
@@ -99,8 +99,8 @@
         m_lineStart = sourcePtrFromOffset(lineStartOffset);
         ASSERT(currentOffset() >= currentLineStartOffset());
 
-        m_buffer8.resize(0);
-        m_buffer16.resize(0);
+        m_buffer8.shrink(0);
+        m_buffer16.shrink(0);
         if (LIKELY(m_code < m_codeEnd))
             m_current = *m_code;
         else

Modified: trunk/Source/_javascript_Core/runtime/RegExpInlines.h (219701 => 219702)


--- trunk/Source/_javascript_Core/runtime/RegExpInlines.h	2017-07-20 20:52:22 UTC (rev 219701)
+++ trunk/Source/_javascript_Core/runtime/RegExpInlines.h	2017-07-20 21:06:12 UTC (rev 219702)
@@ -214,7 +214,7 @@
     int offsetVectorSize = (m_numSubpatterns + 1) * 2;
     int* offsetVector;
     Vector<int, 32> nonReturnedOvector;
-    nonReturnedOvector.resize(offsetVectorSize);
+    nonReturnedOvector.grow(offsetVectorSize);
     offsetVector = nonReturnedOvector.data();
     int r = Yarr::interpret(m_regExpBytecode.get(), s, startOffset, reinterpret_cast<unsigned*>(offsetVector));
 #if REGEXP_FUNC_TEST_DATA_GEN

Modified: trunk/Source/_javascript_Core/runtime/RegExpPrototype.cpp (219701 => 219702)


--- trunk/Source/_javascript_Core/runtime/RegExpPrototype.cpp	2017-07-20 20:52:22 UTC (rev 219701)
+++ trunk/Source/_javascript_Core/runtime/RegExpPrototype.cpp	2017-07-20 21:06:12 UTC (rev 219702)
@@ -515,7 +515,7 @@
         if (control() == AbortSplit)
             return;
         
-        ovector.resize(0);
+        ovector.shrink(0);
         
         // a. Perform ? Set(splitter, "lastIndex", q, true).
         // b. Let z be ? RegExpExec(splitter, S).

Modified: trunk/Source/_javascript_Core/yarr/RegularExpression.cpp (219701 => 219702)


--- trunk/Source/_javascript_Core/yarr/RegularExpression.cpp	2017-07-20 20:52:22 UTC (rev 219701)
+++ trunk/Source/_javascript_Core/yarr/RegularExpression.cpp	2017-07-20 21:06:12 UTC (rev 219702)
@@ -112,7 +112,7 @@
     unsigned* offsetVector;
     Vector<unsigned, 32> nonReturnedOvector;
 
-    nonReturnedOvector.resize(offsetVectorSize);
+    nonReturnedOvector.grow(offsetVectorSize);
     offsetVector = nonReturnedOvector.data();
 
     ASSERT(offsetVector);

Modified: trunk/Source/WTF/ChangeLog (219701 => 219702)


--- trunk/Source/WTF/ChangeLog	2017-07-20 20:52:22 UTC (rev 219701)
+++ trunk/Source/WTF/ChangeLog	2017-07-20 21:06:12 UTC (rev 219702)
@@ -1,3 +1,25 @@
+2017-07-20  Chris Dumez  <[email protected]>
+
+        Replace calls to Vector::resize() with calls to more efficient shrink() / grow() when applicable
+        https://bugs.webkit.org/show_bug.cgi?id=174660
+
+        Reviewed by Geoffrey Garen.
+
+        Replace calls to Vector::resize() with calls to more efficient shrink() / grow() when applicable.
+        This essentially replaces a branch to figure out if the new size is less or greater than the
+        current size by an assertion.
+
+        * wtf/IndexSparseSet.h:
+        (WTF::OverflowHandler>::IndexSparseSet):
+        (WTF::OverflowHandler>::clear):
+        * wtf/Insertion.h:
+        (WTF::executeInsertions):
+        * wtf/RangeSet.h:
+        (WTF::RangeSet::compact):
+        * wtf/Vector.h:
+        (WTF::removeRepeatedElements):
+        * wtf/persistence/Coders.h:
+
 2017-07-20  Yusuke Suzuki  <[email protected]>
 
         [WTF] Use ThreadGroup to bookkeep active threads for Mach exception

Modified: trunk/Source/WTF/wtf/IndexSparseSet.h (219701 => 219702)


--- trunk/Source/WTF/wtf/IndexSparseSet.h	2017-07-20 20:52:22 UTC (rev 219701)
+++ trunk/Source/WTF/wtf/IndexSparseSet.h	2017-07-20 21:06:12 UTC (rev 219702)
@@ -108,7 +108,7 @@
 template<typename EntryType, typename EntryTypeTraits, typename OverflowHandler>
 inline IndexSparseSet<EntryType, EntryTypeTraits, OverflowHandler>::IndexSparseSet(unsigned size)
 {
-    m_map.resize(size);
+    m_map.grow(size);
 }
 
 template<typename EntryType, typename EntryTypeTraits, typename OverflowHandler>
@@ -160,7 +160,7 @@
 template<typename EntryType, typename EntryTypeTraits, typename OverflowHandler>
 void IndexSparseSet<EntryType, EntryTypeTraits, OverflowHandler>::clear()
 {
-    m_values.resize(0);
+    m_values.shrink(0);
 }
 
 template<typename EntryType, typename EntryTypeTraits, typename OverflowHandler>

Modified: trunk/Source/WTF/wtf/Insertion.h (219701 => 219702)


--- trunk/Source/WTF/wtf/Insertion.h	2017-07-20 20:52:22 UTC (rev 219701)
+++ trunk/Source/WTF/wtf/Insertion.h	2017-07-20 21:06:12 UTC (rev 219702)
@@ -73,7 +73,7 @@
         target[firstIndex] = WTFMove(insertions[indexInInsertions].element());
         lastIndex = firstIndex;
     }
-    insertions.resize(0);
+    insertions.shrink(0);
     return numInsertions;
 }
 

Modified: trunk/Source/WTF/wtf/RangeSet.h (219701 => 219702)


--- trunk/Source/WTF/wtf/RangeSet.h	2017-07-20 20:52:22 UTC (rev 219701)
+++ trunk/Source/WTF/wtf/RangeSet.h	2017-07-20 21:06:12 UTC (rev 219702)
@@ -159,7 +159,7 @@
             lastRange = &m_ranges[dstIndex++];
             *lastRange = range;
         }
-        m_ranges.resize(dstIndex);
+        m_ranges.shrink(dstIndex);
 
         m_isCompact = true;
     }

Modified: trunk/Source/WTF/wtf/Vector.h (219701 => 219702)


--- trunk/Source/WTF/wtf/Vector.h	2017-07-20 20:52:22 UTC (rev 219701)
+++ trunk/Source/WTF/wtf/Vector.h	2017-07-20 21:06:12 UTC (rev 219702)
@@ -1536,7 +1536,7 @@
 {
     auto end = std::unique(vector.begin(), vector.end(), func);
     size_t newSize = end - vector.begin();
-    vector.resize(newSize);
+    vector.shrink(newSize);
     return newSize;
 }
 

Modified: trunk/Source/WTF/wtf/persistence/Coders.h (219701 => 219702)


--- trunk/Source/WTF/wtf/persistence/Coders.h	2017-07-20 20:52:22 UTC (rev 219701)
+++ trunk/Source/WTF/wtf/persistence/Coders.h	2017-07-20 21:06:12 UTC (rev 219702)
@@ -182,7 +182,7 @@
             return false;
 
         Vector<T, inlineCapacity> temp;
-        temp.resize(size);
+        temp.grow(size);
 
         decoder.decodeFixedLengthData(reinterpret_cast<uint8_t*>(temp.data()), size * sizeof(T));
 

Modified: trunk/Source/WebCore/ChangeLog (219701 => 219702)


--- trunk/Source/WebCore/ChangeLog	2017-07-20 20:52:22 UTC (rev 219701)
+++ trunk/Source/WebCore/ChangeLog	2017-07-20 21:06:12 UTC (rev 219702)
@@ -1,5 +1,72 @@
 2017-07-20  Chris Dumez  <[email protected]>
 
+        Replace calls to Vector::resize() with calls to more efficient shrink() / grow() when applicable
+        https://bugs.webkit.org/show_bug.cgi?id=174660
+
+        Reviewed by Geoffrey Garen.
+
+        Replace calls to Vector::resize() with calls to more efficient shrink() / grow() when applicable.
+        This essentially replaces a branch to figure out if the new size is less or greater than the
+        current size by an assertion.
+
+        * Modules/gamepad/Gamepad.cpp:
+        (WebCore::Gamepad::Gamepad):
+        * Modules/webaudio/AudioContext.cpp:
+        (WebCore::AudioContext::addReaction):
+        * Modules/websockets/WebSocketChannel.cpp:
+        (WebCore::WebSocketChannel::skipBuffer):
+        * Modules/websockets/WebSocketDeflater.cpp:
+        (WebCore::WebSocketDeflater::finish):
+        * contentextensions/ContentExtensionCompiler.cpp:
+        (WebCore::ContentExtensions::serializeSelector):
+        * contentextensions/DFABytecodeCompiler.cpp:
+        (WebCore::ContentExtensions::append):
+        * crypto/gcrypt/CryptoAlgorithmAES_CBCGCrypt.cpp:
+        (WebCore::gcryptEncrypt):
+        (WebCore::gcryptDecrypt):
+        * crypto/gcrypt/CryptoAlgorithmECDHGCrypt.cpp:
+        (WebCore::gcryptDerive):
+        * platform/gamepad/cocoa/GameControllerGamepadProvider.mm:
+        (WebCore::GameControllerGamepadProvider::controllerDidConnect):
+        * platform/gamepad/mac/HIDGamepadProvider.cpp:
+        (WebCore::HIDGamepadProvider::deviceAdded):
+        * platform/graphics/ImageBackingStore.h:
+        (WebCore::ImageBackingStore::setSize):
+        * platform/graphics/WOFFFileFormat.cpp:
+        * platform/graphics/avfoundation/InbandMetadataTextTrackPrivateAVF.cpp:
+        (WebCore::InbandMetadataTextTrackPrivateAVF::updatePendingCueEndTimes):
+        (WebCore::InbandMetadataTextTrackPrivateAVF::flushPartialCues):
+        * platform/graphics/avfoundation/InbandTextTrackPrivateAVF.cpp:
+        (WebCore::InbandTextTrackPrivateAVF::resetCueValues):
+        (WebCore::InbandTextTrackPrivateAVF::readNativeSampleBuffer):
+        * platform/graphics/avfoundation/cf/InbandTextTrackPrivateAVCF.cpp:
+        (WebCore::InbandTextTrackPrivateAVCF::readNativeSampleBuffer):
+        * platform/graphics/cg/ImageBufferCG.cpp:
+        (WebCore::cfData):
+        * platform/image-decoders/bmp/BMPImageDecoder.cpp:
+        (WebCore::BMPImageDecoder::frameBufferAtIndex):
+        * platform/image-decoders/ico/ICOImageDecoder.cpp:
+        (WebCore::ICOImageDecoder::decode):
+        * platform/image-decoders/jpeg/JPEGImageDecoder.cpp:
+        (WebCore::JPEGImageDecoder::frameBufferAtIndex):
+        * platform/image-decoders/png/PNGImageDecoder.cpp:
+        (WebCore::PNGImageDecoder::frameBufferAtIndex):
+        (WebCore::PNGImageDecoder::readChunks):
+        * platform/image-decoders/webp/WEBPImageDecoder.cpp:
+        (WebCore::WEBPImageDecoder::frameBufferAtIndex):
+        * platform/image-encoders/JPEGImageEncoder.cpp:
+        (WebCore::compressRGBABigEndianToJPEG):
+        * platform/text/DecodeEscapeSequences.h:
+        (WebCore::URLEscapeSequence::decodeRun):
+        * platform/text/SuffixTree.h:
+        (WebCore::SuffixTree::Node::Node):
+        * rendering/Grid.cpp:
+        (WebCore::Grid::setNeedsItemsPlacement):
+        * rendering/RenderTable.cpp:
+        (WebCore::RenderTable::invalidateCachedColumns):
+
+2017-07-20  Chris Dumez  <[email protected]>
+
         Regression(ITP): Can no longer log in on abc.go.com
         https://bugs.webkit.org/show_bug.cgi?id=174533
         <rdar://problem/33325881>

Modified: trunk/Source/WebCore/Modules/gamepad/Gamepad.cpp (219701 => 219702)


--- trunk/Source/WebCore/Modules/gamepad/Gamepad.cpp	2017-07-20 20:52:22 UTC (rev 219701)
+++ trunk/Source/WebCore/Modules/gamepad/Gamepad.cpp	2017-07-20 21:06:12 UTC (rev 219702)
@@ -39,9 +39,8 @@
     , m_index(platformGamepad.index())
     , m_connected(true)
     , m_timestamp(platformGamepad.lastUpdateTime())
+    , m_axes(platformGamepad.axisValues().size(), 0.0)
 {
-    m_axes.resize(platformGamepad.axisValues().size());
-    m_axes.fill(0.0);
     unsigned buttonCount = platformGamepad.buttonValues().size();
     for (unsigned i = 0; i < buttonCount; ++i)
         m_buttons.append(GamepadButton::create());

Modified: trunk/Source/WebCore/Modules/webaudio/AudioContext.cpp (219701 => 219702)


--- trunk/Source/WebCore/Modules/webaudio/AudioContext.cpp	2017-07-20 20:52:22 UTC (rev 219701)
+++ trunk/Source/WebCore/Modules/webaudio/AudioContext.cpp	2017-07-20 21:06:12 UTC (rev 219702)
@@ -289,7 +289,7 @@
 {
     size_t stateIndex = static_cast<size_t>(state);
     if (stateIndex >= m_stateReactions.size())
-        m_stateReactions.resize(stateIndex + 1);
+        m_stateReactions.grow(stateIndex + 1);
 
     m_stateReactions[stateIndex].append(WTFMove(promise));
 }

Modified: trunk/Source/WebCore/Modules/websockets/WebSocketChannel.cpp (219701 => 219702)


--- trunk/Source/WebCore/Modules/websockets/WebSocketChannel.cpp	2017-07-20 20:52:22 UTC (rev 219701)
+++ trunk/Source/WebCore/Modules/websockets/WebSocketChannel.cpp	2017-07-20 21:06:12 UTC (rev 219702)
@@ -418,7 +418,7 @@
 {
     ASSERT_WITH_SECURITY_IMPLICATION(len <= m_buffer.size());
     memmove(m_buffer.data(), m_buffer.data() + len, m_buffer.size() - len);
-    m_buffer.resize(m_buffer.size() - len);
+    m_buffer.shrink(m_buffer.size() - len);
 }
 
 bool WebSocketChannel::processBuffer()

Modified: trunk/Source/WebCore/Modules/websockets/WebSocketDeflater.cpp (219701 => 219702)


--- trunk/Source/WebCore/Modules/websockets/WebSocketDeflater.cpp	2017-07-20 20:52:22 UTC (rev 219701)
+++ trunk/Source/WebCore/Modules/websockets/WebSocketDeflater.cpp	2017-07-20 21:06:12 UTC (rev 219702)
@@ -111,7 +111,7 @@
     // Remove 4 octets from the tail as the specification requires.
     if (m_buffer.size() <= 4)
         return false;
-    m_buffer.resize(m_buffer.size() - 4);
+    m_buffer.shrink(m_buffer.size() - 4);
     return true;
 }
 

Modified: trunk/Source/WebCore/contentextensions/ContentExtensionCompiler.cpp (219701 => 219702)


--- trunk/Source/WebCore/contentextensions/ContentExtensionCompiler.cpp	2017-07-20 20:52:22 UTC (rev 219701)
+++ trunk/Source/WebCore/contentextensions/ContentExtensionCompiler.cpp	2017-07-20 21:06:12 UTC (rev 219702)
@@ -54,7 +54,7 @@
     actions.append(static_cast<SerializedActionByte>(ActionType::CSSDisplayNoneSelector));
     // Append Selector length (4 bytes).
     unsigned selectorLength = selector.length();
-    actions.resize(actions.size() + sizeof(unsigned));
+    actions.grow(actions.size() + sizeof(unsigned));
     *reinterpret_cast<unsigned*>(&actions[actions.size() - sizeof(unsigned)]) = selectorLength;
     bool wideCharacters = !selector.is8Bit();
     actions.append(wideCharacters);
@@ -61,7 +61,7 @@
     // Append Selector.
     if (wideCharacters) {
         unsigned startIndex = actions.size();
-        actions.resize(actions.size() + sizeof(UChar) * selectorLength);
+        actions.grow(actions.size() + sizeof(UChar) * selectorLength);
         for (unsigned i = 0; i < selectorLength; ++i)
             *reinterpret_cast<UChar*>(&actions[startIndex + i * sizeof(UChar)]) = selector[i];
     } else {

Modified: trunk/Source/WebCore/contentextensions/DFABytecodeCompiler.cpp (219701 => 219702)


--- trunk/Source/WebCore/contentextensions/DFABytecodeCompiler.cpp	2017-07-20 20:52:22 UTC (rev 219701)
+++ trunk/Source/WebCore/contentextensions/DFABytecodeCompiler.cpp	2017-07-20 21:06:12 UTC (rev 219702)
@@ -39,7 +39,7 @@
 template <typename IntType>
 inline void append(Vector<DFABytecode>& bytecode, IntType value)
 {
-    bytecode.resize(bytecode.size() + sizeof(IntType));
+    bytecode.grow(bytecode.size() + sizeof(IntType));
     *reinterpret_cast<IntType*>(&bytecode[bytecode.size() - sizeof(IntType)]) = value;
 }
 

Modified: trunk/Source/WebCore/crypto/gcrypt/CryptoAlgorithmAES_CBCGCrypt.cpp (219701 => 219702)


--- trunk/Source/WebCore/crypto/gcrypt/CryptoAlgorithmAES_CBCGCrypt.cpp	2017-07-20 20:52:22 UTC (rev 219701)
+++ trunk/Source/WebCore/crypto/gcrypt/CryptoAlgorithmAES_CBCGCrypt.cpp	2017-07-20 21:06:12 UTC (rev 219702)
@@ -79,7 +79,7 @@
             return std::nullopt;
         uint8_t paddingValue = paddedSize - size;
 
-        plainText.resize(paddedSize);
+        plainText.grow(paddedSize);
         std::memset(plainText.data() + size, paddingValue, paddingValue);
     }
 
@@ -162,7 +162,7 @@
             return std::nullopt;
 
         // Shrink the output Vector object to drop the PKCS#7 padding.
-        output.resize(size - paddingValue);
+        output.shrink(size - paddingValue);
     }
 
     return output;

Modified: trunk/Source/WebCore/crypto/gcrypt/CryptoAlgorithmECDHGCrypt.cpp (219701 => 219702)


--- trunk/Source/WebCore/crypto/gcrypt/CryptoAlgorithmECDHGCrypt.cpp	2017-07-20 20:52:22 UTC (rev 219701)
+++ trunk/Source/WebCore/crypto/gcrypt/CryptoAlgorithmECDHGCrypt.cpp	2017-07-20 21:06:12 UTC (rev 219702)
@@ -105,7 +105,7 @@
             return std::nullopt;
         }
 
-        output.resize(dataLength);
+        output.grow(dataLength);
         error = gcry_mpi_print(GCRYMPI_FMT_USG, output.data(), output.size(), nullptr, xMPI);
         if (error != GPG_ERR_NO_ERROR) {
             PAL::GCrypt::logError(error);

Modified: trunk/Source/WebCore/platform/gamepad/cocoa/GameControllerGamepadProvider.mm (219701 => 219702)


--- trunk/Source/WebCore/platform/gamepad/cocoa/GameControllerGamepadProvider.mm	2017-07-20 20:52:22 UTC (rev 219701)
+++ trunk/Source/WebCore/platform/gamepad/cocoa/GameControllerGamepadProvider.mm	2017-07-20 21:06:12 UTC (rev 219702)
@@ -64,7 +64,7 @@
     auto gamepad = std::make_unique<GameControllerGamepad>(controller, index);
 
     if (m_gamepadVector.size() <= index)
-        m_gamepadVector.resize(index + 1);
+        m_gamepadVector.grow(index + 1);
 
     m_gamepadVector[index] = gamepad.get();
     m_gamepadMap.set(controller, WTFMove(gamepad));

Modified: trunk/Source/WebCore/platform/gamepad/mac/HIDGamepadProvider.cpp (219701 => 219702)


--- trunk/Source/WebCore/platform/gamepad/mac/HIDGamepadProvider.cpp	2017-07-20 20:52:22 UTC (rev 219701)
+++ trunk/Source/WebCore/platform/gamepad/mac/HIDGamepadProvider.cpp	2017-07-20 21:06:12 UTC (rev 219702)
@@ -191,7 +191,7 @@
     std::unique_ptr<HIDGamepad> gamepad = std::make_unique<HIDGamepad>(device, index);
 
     if (m_gamepadVector.size() <= index)
-        m_gamepadVector.resize(index + 1);
+        m_gamepadVector.grow(index + 1);
 
     m_gamepadVector[index] = gamepad.get();
     m_gamepadMap.set(device, WTFMove(gamepad));

Modified: trunk/Source/WebCore/platform/graphics/ImageBackingStore.h (219701 => 219702)


--- trunk/Source/WebCore/platform/graphics/ImageBackingStore.h	2017-07-20 20:52:22 UTC (rev 219701)
+++ trunk/Source/WebCore/platform/graphics/ImageBackingStore.h	2017-07-20 21:06:12 UTC (rev 219702)
@@ -59,7 +59,7 @@
         if (!buffer.tryReserveCapacity(bufferSize))
             return false;
 
-        buffer.resize(bufferSize);
+        buffer.grow(bufferSize);
         m_pixels = SharedBuffer::create(WTFMove(buffer));
         m_pixelsPtr = reinterpret_cast<RGBA32*>(const_cast<char*>(m_pixels->data()));
         m_size = size;

Modified: trunk/Source/WebCore/platform/graphics/WOFFFileFormat.cpp (219701 => 219702)


--- trunk/Source/WebCore/platform/graphics/WOFFFileFormat.cpp	2017-07-20 20:52:22 UTC (rev 219701)
+++ trunk/Source/WebCore/platform/graphics/WOFFFileFormat.cpp	2017-07-20 21:06:12 UTC (rev 219702)
@@ -110,7 +110,7 @@
         if (!m_vector.tryReserveCapacity(offset + n))
             return false;
         if (offset + n > m_vector.size())
-            m_vector.resize(offset + n);
+            m_vector.grow(offset + n);
         m_vector.remove(offset, n);
         m_vector.insert(offset, static_cast<const char*>(data), n);
         return true;

Modified: trunk/Source/WebCore/platform/graphics/avfoundation/InbandMetadataTextTrackPrivateAVF.cpp (219701 => 219702)


--- trunk/Source/WebCore/platform/graphics/avfoundation/InbandMetadataTextTrackPrivateAVF.cpp	2017-07-20 20:52:22 UTC (rev 219701)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/InbandMetadataTextTrackPrivateAVF.cpp	2017-07-20 21:06:12 UTC (rev 219702)
@@ -83,7 +83,7 @@
     } else
         LOG(Media, "InbandMetadataTextTrackPrivateAVF::updatePendingCueEndTimes negative length cue(s) ignored: start=%s, end=%s\n", toString(m_currentCueStartTime).utf8().data(), toString(time).utf8().data());
 
-    m_incompleteCues.resize(0);
+    m_incompleteCues.shrink(0);
     m_currentCueStartTime = MediaTime::zeroTime();
 }
 
@@ -99,7 +99,7 @@
             client()->removeDataCue(partialCue.startTime, MediaTime::positiveInfiniteTime(), *partialCue.cueData);
     }
 
-    m_incompleteCues.resize(0);
+    m_incompleteCues.shrink(0);
     m_currentCueStartTime = MediaTime::zeroTime();
 }
 

Modified: trunk/Source/WebCore/platform/graphics/avfoundation/InbandTextTrackPrivateAVF.cpp (219701 => 219702)


--- trunk/Source/WebCore/platform/graphics/avfoundation/InbandTextTrackPrivateAVF.cpp	2017-07-20 20:52:22 UTC (rev 219701)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/InbandTextTrackPrivateAVF.cpp	2017-07-20 21:06:12 UTC (rev 219702)
@@ -449,7 +449,7 @@
             client->removeGenericCue(*cue);
     }
 
-    m_cues.resize(0);
+    m_cues.shrink(0);
     m_pendingCueStatus = None;
     m_currentCueStartTime = MediaTime::zeroTime();
     m_currentCueEndTime = MediaTime::zeroTime();
@@ -568,7 +568,7 @@
         return false;
     }
 
-    m_sampleInputBuffer.resize(m_sampleInputBuffer.size() + bufferLength);
+    m_sampleInputBuffer.grow(m_sampleInputBuffer.size() + bufferLength);
     CMBlockBufferCopyDataBytes(blockBuffer, 0, bufferLength, m_sampleInputBuffer.data() + m_sampleInputBuffer.size() - bufferLength);
 
     buffer = ArrayBuffer::create(m_sampleInputBuffer.data(), m_sampleInputBuffer.size());

Modified: trunk/Source/WebCore/platform/graphics/avfoundation/cf/InbandTextTrackPrivateAVCF.cpp (219701 => 219702)


--- trunk/Source/WebCore/platform/graphics/avfoundation/cf/InbandTextTrackPrivateAVCF.cpp	2017-07-20 20:52:22 UTC (rev 219701)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/cf/InbandTextTrackPrivateAVCF.cpp	2017-07-20 21:06:12 UTC (rev 219702)
@@ -203,7 +203,7 @@
         return false;
     }
 
-    m_sampleInputBuffer.resize(m_sampleInputBuffer.size() + bufferLength);
+    m_sampleInputBuffer.grow(m_sampleInputBuffer.size() + bufferLength);
     CFDataGetBytes(sampleBuffer->buffer, CFRangeMake(0, bufferLength), reinterpret_cast<UInt8*>(m_sampleInputBuffer.data()) + m_sampleInputBuffer.size() - bufferLength);
 
     buffer = ArrayBuffer::create(m_sampleInputBuffer.data(), m_sampleInputBuffer.size());

Modified: trunk/Source/WebCore/platform/graphics/cg/ImageBufferCG.cpp (219701 => 219702)


--- trunk/Source/WebCore/platform/graphics/cg/ImageBufferCG.cpp	2017-07-20 20:52:22 UTC (rev 219701)
+++ trunk/Source/WebCore/platform/graphics/cg/ImageBufferCG.cpp	2017-07-20 21:06:12 UTC (rev 219702)
@@ -587,7 +587,7 @@
         if (!premultipliedData.tryReserveCapacity(size))
             return nullptr;
 
-        premultipliedData.resize(size);
+        premultipliedData.grow(size);
         unsigned char *buffer = premultipliedData.data();
         for (size_t i = 0; i < size; i += 4) {
             unsigned alpha = data[i + 3];

Modified: trunk/Source/WebCore/platform/image-decoders/bmp/BMPImageDecoder.cpp (219701 => 219702)


--- trunk/Source/WebCore/platform/image-decoders/bmp/BMPImageDecoder.cpp	2017-07-20 20:52:22 UTC (rev 219701)
+++ trunk/Source/WebCore/platform/image-decoders/bmp/BMPImageDecoder.cpp	2017-07-20 21:06:12 UTC (rev 219702)
@@ -62,7 +62,7 @@
         return 0;
 
     if (m_frameBufferCache.isEmpty())
-        m_frameBufferCache.resize(1);
+        m_frameBufferCache.grow(1);
 
     ImageFrame* buffer = &m_frameBufferCache.first();
     if (!buffer->isComplete())

Modified: trunk/Source/WebCore/platform/image-decoders/ico/ICOImageDecoder.cpp (219701 => 219702)


--- trunk/Source/WebCore/platform/image-decoders/ico/ICOImageDecoder.cpp	2017-07-20 20:52:22 UTC (rev 219701)
+++ trunk/Source/WebCore/platform/image-decoders/ico/ICOImageDecoder.cpp	2017-07-20 21:06:12 UTC (rev 219702)
@@ -168,7 +168,7 @@
     }
     
     if (m_frameBufferCache.isEmpty())
-        m_frameBufferCache.resize(m_dirEntries.size());
+        m_frameBufferCache.grow(m_dirEntries.size());
     // CAUTION: We must not resize m_frameBufferCache again after this, as
     // decodeAtIndex() may give a BMPImageReader a pointer to one of the
     // entries.

Modified: trunk/Source/WebCore/platform/image-decoders/jpeg/JPEGImageDecoder.cpp (219701 => 219702)


--- trunk/Source/WebCore/platform/image-decoders/jpeg/JPEGImageDecoder.cpp	2017-07-20 20:52:22 UTC (rev 219701)
+++ trunk/Source/WebCore/platform/image-decoders/jpeg/JPEGImageDecoder.cpp	2017-07-20 21:06:12 UTC (rev 219702)
@@ -525,7 +525,7 @@
         return 0;
 
     if (m_frameBufferCache.isEmpty())
-        m_frameBufferCache.resize(1);
+        m_frameBufferCache.grow(1);
 
     ImageFrame& frame = m_frameBufferCache[0];
     if (!frame.isComplete())

Modified: trunk/Source/WebCore/platform/image-decoders/png/PNGImageDecoder.cpp (219701 => 219702)


--- trunk/Source/WebCore/platform/image-decoders/png/PNGImageDecoder.cpp	2017-07-20 20:52:22 UTC (rev 219701)
+++ trunk/Source/WebCore/platform/image-decoders/png/PNGImageDecoder.cpp	2017-07-20 21:06:12 UTC (rev 219702)
@@ -270,7 +270,7 @@
 #endif
 
     if (m_frameBufferCache.isEmpty())
-        m_frameBufferCache.resize(1);
+        m_frameBufferCache.grow(1);
 
     ImageFrame& frame = m_frameBufferCache[index];
     if (!frame.isComplete())
@@ -644,7 +644,7 @@
         }
 
         if (m_frameBufferCache.isEmpty())
-            m_frameBufferCache.resize(1);
+            m_frameBufferCache.grow(1);
 
         if (m_currentFrame < m_frameBufferCache.size()) {
             ImageFrame& buffer = m_frameBufferCache[m_currentFrame];

Modified: trunk/Source/WebCore/platform/image-decoders/webp/WEBPImageDecoder.cpp (219701 => 219702)


--- trunk/Source/WebCore/platform/image-decoders/webp/WEBPImageDecoder.cpp	2017-07-20 20:52:22 UTC (rev 219701)
+++ trunk/Source/WebCore/platform/image-decoders/webp/WEBPImageDecoder.cpp	2017-07-20 21:06:12 UTC (rev 219702)
@@ -70,7 +70,7 @@
         return 0;
 
     if (m_frameBufferCache.isEmpty())
-        m_frameBufferCache.resize(1);
+        m_frameBufferCache.grow(1);
 
     ImageFrame& frame = m_frameBufferCache[0];
     if (!frame.isComplete())

Modified: trunk/Source/WebCore/platform/image-encoders/JPEGImageEncoder.cpp (219701 => 219702)


--- trunk/Source/WebCore/platform/image-encoders/JPEGImageEncoder.cpp	2017-07-20 20:52:22 UTC (rev 219701)
+++ trunk/Source/WebCore/platform/image-encoders/JPEGImageEncoder.cpp	2017-07-20 21:06:12 UTC (rev 219702)
@@ -119,7 +119,7 @@
     }
 
     jpeg_start_compress(&compressData, TRUE);
-    rowBuffer.resize(compressData.image_width * 3);
+    rowBuffer.grow(compressData.image_width * 3);
 
     // add offset to prevent clobbered error caused by setjmp and longjmp.
     unsigned offset = 0;

Modified: trunk/Source/WebCore/platform/text/DecodeEscapeSequences.h (219701 => 219702)


--- trunk/Source/WebCore/platform/text/DecodeEscapeSequences.h	2017-07-20 20:52:22 UTC (rev 219701)
+++ trunk/Source/WebCore/platform/text/DecodeEscapeSequences.h	2017-07-20 21:06:12 UTC (rev 219702)
@@ -102,7 +102,7 @@
         // For URL escape sequences, we know that findEndOfRun() has given us a run where every %-sign introduces
         // a valid escape sequence, but there may be characters between the sequences.
         Vector<char, 512> buffer;
-        buffer.resize(run.length()); // Unescaping hex sequences only makes the length smaller.
+        buffer.grow(run.length()); // Unescaping hex sequences only makes the length smaller.
         char* p = buffer.data();
         while (!run.isEmpty()) {
             if (run[0] == '%') {

Modified: trunk/Source/WebCore/platform/text/SuffixTree.h (219701 => 219702)


--- trunk/Source/WebCore/platform/text/SuffixTree.h	2017-07-20 20:52:22 UTC (rev 219701)
+++ trunk/Source/WebCore/platform/text/SuffixTree.h	2017-07-20 21:06:12 UTC (rev 219702)
@@ -69,10 +69,9 @@
     class Node {
     public:
         Node(bool isLeaf = false)
+            : m_children(Codebook::codeSize, 0)
+            , m_isLeaf(isLeaf)
         {
-            m_children.resize(Codebook::codeSize);
-            m_children.fill(0);
-            m_isLeaf = isLeaf;
         }
 
         ~Node()

Modified: trunk/Source/WebCore/rendering/Grid.cpp (219701 => 219702)


--- trunk/Source/WebCore/rendering/Grid.cpp	2017-07-20 20:52:22 UTC (rev 219701)
+++ trunk/Source/WebCore/rendering/Grid.cpp	2017-07-20 21:06:12 UTC (rev 219702)
@@ -155,7 +155,7 @@
         return;
     }
 
-    m_grid.resize(0);
+    m_grid.shrink(0);
     m_gridItemArea.clear();
     m_hasAnyOrthogonalGridItem = false;
     m_smallestRowStart = 0;

Modified: trunk/Source/WebCore/rendering/RenderTable.cpp (219701 => 219702)


--- trunk/Source/WebCore/rendering/RenderTable.cpp	2017-07-20 20:52:22 UTC (rev 219701)
+++ trunk/Source/WebCore/rendering/RenderTable.cpp	2017-07-20 21:06:12 UTC (rev 219702)
@@ -239,7 +239,7 @@
 void RenderTable::invalidateCachedColumns()
 {
     m_columnRenderersValid = false;
-    m_columnRenderers.resize(0);
+    m_columnRenderers.shrink(0);
     m_effectiveColumnIndexMap.clear();
 }
 

Modified: trunk/Source/WebKit/ChangeLog (219701 => 219702)


--- trunk/Source/WebKit/ChangeLog	2017-07-20 20:52:22 UTC (rev 219701)
+++ trunk/Source/WebKit/ChangeLog	2017-07-20 21:06:12 UTC (rev 219702)
@@ -1,5 +1,28 @@
 2017-07-20  Chris Dumez  <[email protected]>
 
+        Replace calls to Vector::resize() with calls to more efficient shrink() / grow() when applicable
+        https://bugs.webkit.org/show_bug.cgi?id=174660
+
+        Reviewed by Geoffrey Garen.
+
+        Replace calls to Vector::resize() with calls to more efficient shrink() / grow() when applicable.
+        This essentially replaces a branch to figure out if the new size is less or greater than the
+        current size by an assertion.
+
+        * Platform/IPC/ArgumentCoders.h:
+        * UIProcess/Gamepad/UIGamepadProvider.cpp:
+        (WebKit::UIGamepadProvider::platformGamepadConnected):
+        * UIProcess/WebProcessPool.cpp:
+        (WebKit::WebProcessPool::setInitialConnectedGamepads):
+        * WebProcess/Network/WebLoaderStrategy.cpp:
+        (WebKit::WebLoaderStrategy::loadResourceSynchronously):
+        * WebProcess/WebCoreSupport/WebPasteboardOverrides.cpp:
+        (WebKit::WebPasteboardOverrides::getDataForOverride):
+        * WebProcess/WebPage/ios/WebPageIOS.mm:
+        (WebKit::WebPage::requestAutocorrectionData):
+
+2017-07-20  Chris Dumez  <[email protected]>
+
         Regression(ITP): Can no longer log in on abc.go.com
         https://bugs.webkit.org/show_bug.cgi?id=174533
         <rdar://problem/33325881>

Modified: trunk/Source/WebKit/Platform/IPC/ArgumentCoders.h (219701 => 219702)


--- trunk/Source/WebKit/Platform/IPC/ArgumentCoders.h	2017-07-20 20:52:22 UTC (rev 219701)
+++ trunk/Source/WebKit/Platform/IPC/ArgumentCoders.h	2017-07-20 21:06:12 UTC (rev 219702)
@@ -257,7 +257,7 @@
         }
 
         Vector<T, inlineCapacity> temp;
-        temp.resize(size);
+        temp.grow(size);
 
         decoder.decodeFixedLengthData(reinterpret_cast<uint8_t*>(temp.data()), size * sizeof(T), alignof(T));
 

Modified: trunk/Source/WebKit/UIProcess/Gamepad/UIGamepadProvider.cpp (219701 => 219702)


--- trunk/Source/WebKit/UIProcess/Gamepad/UIGamepadProvider.cpp	2017-07-20 20:52:22 UTC (rev 219701)
+++ trunk/Source/WebKit/UIProcess/Gamepad/UIGamepadProvider.cpp	2017-07-20 21:06:12 UTC (rev 219702)
@@ -104,7 +104,7 @@
 void UIGamepadProvider::platformGamepadConnected(PlatformGamepad& gamepad)
 {
     if (m_gamepads.size() <= gamepad.index())
-        m_gamepads.resize(gamepad.index() + 1);
+        m_gamepads.grow(gamepad.index() + 1);
 
     ASSERT(!m_gamepads[gamepad.index()]);
     m_gamepads[gamepad.index()] = std::make_unique<UIGamepad>(gamepad);

Modified: trunk/Source/WebKit/UIProcess/WebProcessPool.cpp (219701 => 219702)


--- trunk/Source/WebKit/UIProcess/WebProcessPool.cpp	2017-07-20 20:52:22 UTC (rev 219701)
+++ trunk/Source/WebKit/UIProcess/WebProcessPool.cpp	2017-07-20 21:06:12 UTC (rev 219702)
@@ -1541,7 +1541,7 @@
 void WebProcessPool::setInitialConnectedGamepads(const Vector<std::unique_ptr<UIGamepad>>& gamepads)
 {
     Vector<GamepadData> gamepadDatas;
-    gamepadDatas.resize(gamepads.size());
+    gamepadDatas.grow(gamepads.size());
     for (size_t i = 0; i < gamepads.size(); ++i) {
         if (!gamepads[i])
             continue;

Modified: trunk/Source/WebKit/WebProcess/Network/WebLoaderStrategy.cpp (219701 => 219702)


--- trunk/Source/WebKit/WebProcess/Network/WebLoaderStrategy.cpp	2017-07-20 20:52:22 UTC (rev 219701)
+++ trunk/Source/WebKit/WebProcess/Network/WebLoaderStrategy.cpp	2017-07-20 21:06:12 UTC (rev 219702)
@@ -369,7 +369,7 @@
     loadParameters.clientCredentialPolicy = clientCredentialPolicy;
     loadParameters.shouldClearReferrerOnHTTPSToHTTPRedirect = context->shouldClearReferrerOnHTTPSToHTTPRedirect();
 
-    data.resize(0);
+    data.shrink(0);
 
     HangDetectionDisabler hangDetectionDisabler;
 

Modified: trunk/Source/WebKit/WebProcess/WebCoreSupport/WebPasteboardOverrides.cpp (219701 => 219702)


--- trunk/Source/WebKit/WebProcess/WebCoreSupport/WebPasteboardOverrides.cpp	2017-07-20 20:52:22 UTC (rev 219701)
+++ trunk/Source/WebKit/WebProcess/WebCoreSupport/WebPasteboardOverrides.cpp	2017-07-20 21:06:12 UTC (rev 219702)
@@ -103,7 +103,6 @@
     if (!getDataForOverride(pasteboardName, type, foundBuffer))
         return false;
 
-    data.clear();
     data.resize(foundBuffer.size());
     memcpy(data.data(), foundBuffer.data(), foundBuffer.size());
 

Modified: trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm (219701 => 219702)


--- trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm	2017-07-20 20:52:22 UTC (rev 219701)
+++ trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm	2017-07-20 21:06:12 UTC (rev 219702)
@@ -2221,7 +2221,7 @@
         range->collectSelectionRects(selectionRects);
 
     Vector<FloatRect> rectsForText;
-    rectsForText.resize(selectionRects.size());
+    rectsForText.grow(selectionRects.size());
 
     convertSelectionRectsToRootView(frame.view(), selectionRects);
     for (size_t i = 0; i < selectionRects.size(); i++)

Modified: trunk/Source/WebKitLegacy/mac/ChangeLog (219701 => 219702)


--- trunk/Source/WebKitLegacy/mac/ChangeLog	2017-07-20 20:52:22 UTC (rev 219701)
+++ trunk/Source/WebKitLegacy/mac/ChangeLog	2017-07-20 21:06:12 UTC (rev 219702)
@@ -1,3 +1,17 @@
+2017-07-20  Chris Dumez  <[email protected]>
+
+        Replace calls to Vector::resize() with calls to more efficient shrink() / grow() when applicable
+        https://bugs.webkit.org/show_bug.cgi?id=174660
+
+        Reviewed by Geoffrey Garen.
+
+        Replace calls to Vector::resize() with calls to more efficient shrink() / grow() when applicable.
+        This essentially replaces a branch to figure out if the new size is less or greater than the
+        current size by an assertion.
+
+        * Plugins/WebNetscapePluginView.mm:
+        (-[WebNetscapePluginView saveAndSetNewPortStateForUpdate:]):
+
 2017-07-20  Brady Eidson  <[email protected]>
 
         Deprecate WebIconDatabase in WebKitLegacy/mac.

Modified: trunk/Source/WebKitLegacy/mac/Plugins/WebNetscapePluginView.mm (219701 => 219702)


--- trunk/Source/WebKitLegacy/mac/Plugins/WebNetscapePluginView.mm	2017-07-20 20:52:22 UTC (rev 219701)
+++ trunk/Source/WebKitLegacy/mac/Plugins/WebNetscapePluginView.mm	2017-07-20 21:06:12 UTC (rev 219702)
@@ -529,7 +529,7 @@
                 NSInteger count;
                 [opaqueAncestor getRectsBeingDrawn:&dirtyRects count:&count];
                 Vector<CGRect, 16> convertedDirtyRects;
-                convertedDirtyRects.resize(count);
+                convertedDirtyRects.grow(count);
                 for (int i = 0; i < count; ++i)
                     reinterpret_cast<NSRect&>(convertedDirtyRects[i]) = [self convertRect:dirtyRects[i] fromView:opaqueAncestor];
                 CGContextClipToRects(context, convertedDirtyRects.data(), count);

Modified: trunk/Source/bmalloc/ChangeLog (219701 => 219702)


--- trunk/Source/bmalloc/ChangeLog	2017-07-20 20:52:22 UTC (rev 219701)
+++ trunk/Source/bmalloc/ChangeLog	2017-07-20 21:06:12 UTC (rev 219702)
@@ -1,3 +1,17 @@
+2017-07-20  Chris Dumez  <[email protected]>
+
+        Replace calls to Vector::resize() with calls to more efficient shrink() / grow() when applicable
+        https://bugs.webkit.org/show_bug.cgi?id=174660
+
+        Reviewed by Geoffrey Garen.
+
+        Replace calls to Vector::resize() with calls to more efficient shrink() / grow() when applicable.
+        This essentially replaces a branch to figure out if the new size is less or greater than the
+        current size by an assertion.
+
+        * bmalloc/Map.h:
+        (bmalloc::Hash>::rehash):
+
 2017-07-18  Andy Estes  <[email protected]>
 
         [Xcode] Enable CLANG_WARN_RANGE_LOOP_ANALYSIS

Modified: trunk/Source/bmalloc/bmalloc/Map.h (219701 => 219702)


--- trunk/Source/bmalloc/bmalloc/Map.h	2017-07-20 20:52:22 UTC (rev 219701)
+++ trunk/Source/bmalloc/bmalloc/Map.h	2017-07-20 21:06:12 UTC (rev 219702)
@@ -113,7 +113,7 @@
     auto oldTable = std::move(m_table);
 
     size_t newCapacity = std::max(minCapacity, m_keyCount * rehashLoad);
-    m_table.resize(newCapacity);
+    m_table.grow(newCapacity);
 
     m_keyCount = 0;
     m_tableMask = newCapacity - 1;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to