Diff
Modified: trunk/Source/WebCore/ChangeLog (209399 => 209400)
--- trunk/Source/WebCore/ChangeLog 2016-12-06 17:18:20 UTC (rev 209399)
+++ trunk/Source/WebCore/ChangeLog 2016-12-06 17:42:37 UTC (rev 209400)
@@ -1,3 +1,48 @@
+2016-12-06 Daniel Bates <daba...@apple.com>
+
+ Use Vector::uncheckedAppend() in more places
+ https://bugs.webkit.org/show_bug.cgi?id=164952
+
+ Reviewed by Darin Adler.
+
+ We can use Vector::uncheckedAppend() whenever the number of items that will be appended
+ to a vector is equal to or less than its capacity. Using Vector::uncheckedAppend() is
+ more efficient than Vector::append() as it avoids checking the capacity of the vector
+ before appending a value to the end of it.
+
+ * bindings/js/SerializedScriptValue.cpp:
+ (WebCore::SerializedScriptValue::SerializedScriptValue):
+ * contentextensions/DFABytecodeCompiler.cpp:
+ (WebCore::ContentExtensions::DFABytecodeCompiler::extractJumpTable):
+ * contentextensions/DFAMinimizer.cpp:
+ * css/StyleProperties.cpp:
+ (WebCore::StyleProperties::copyPropertiesInSet): Use Vector::uncheckedAppend() and inline
+ the assignment of the temporary variable value into the if condition to limit its scope
+ as it is referenced exactly once in the loop body.
+ * css/StyleRule.cpp:
+ (WebCore::StyleRuleGroup::StyleRuleGroup): Use Vector::uncheckedAppend() and write for-loop
+ using a C++11 range-based for-loop.
+ * css/parser/CSSParserValues.cpp:
+ (WebCore::CSSParserSelector::setLangArgumentList):
+ * cssjit/SelectorCompiler.cpp:
+ (WebCore::SelectorCompiler::SelectorCodeGenerator::generateElementIsNthLastChildOf):
+ * dom/DocumentMarkerController.cpp:
+ (WebCore::updateRenderedRectsForMarker):
+ * page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.mm:
+ (WebCore::convertToLayoutUnits):
+ * platform/audio/AudioBus.cpp:
+ (WebCore::AudioBus::AudioBus):
+ * platform/graphics/FontCache.cpp:
+ (WebCore::FontCache::purgeInactiveFontData):
+ * platform/graphics/PathUtilities.cpp:
+ (WebCore::polygonsForRect):
+ * platform/mediastream/CaptureDeviceManager.cpp:
+ (CaptureDeviceManager::bestSourcesForTypeAndConstraints):
+ * platform/mediastream/RealtimeMediaSource.cpp:
+ (WebCore::RealtimeMediaSource::fitnessDistance):
+ * platform/network/cf/FormDataStreamCFNet.cpp:
+ (WebCore::formCreate):
+
2016-12-04 Darin Adler <da...@apple.com>
Use ASCIICType more, and improve it a little bit
Modified: trunk/Source/WebCore/bindings/js/SerializedScriptValue.cpp (209399 => 209400)
--- trunk/Source/WebCore/bindings/js/SerializedScriptValue.cpp 2016-12-06 17:18:20 UTC (rev 209399)
+++ trunk/Source/WebCore/bindings/js/SerializedScriptValue.cpp 2016-12-06 17:42:37 UTC (rev 209400)
@@ -2660,7 +2660,7 @@
// need to be isolatedCopies so we don't run into thread safety issues for the StringImpls.
m_blobURLs.reserveInitialCapacity(blobURLs.size());
for (auto& url : blobURLs)
- m_blobURLs.append(url.isolatedCopy());
+ m_blobURLs.uncheckedAppend(url.isolatedCopy());
}
static ExceptionOr<std::unique_ptr<ArrayBufferContentsArray>> transferArrayBuffers(const Vector<RefPtr<JSC::ArrayBuffer>>& arrayBuffers)
Modified: trunk/Source/WebCore/contentextensions/DFABytecodeCompiler.cpp (209399 => 209400)
--- trunk/Source/WebCore/contentextensions/DFABytecodeCompiler.cpp 2016-12-06 17:18:20 UTC (rev 209399)
+++ trunk/Source/WebCore/contentextensions/DFABytecodeCompiler.cpp 2016-12-06 17:42:37 UTC (rev 209400)
@@ -218,7 +218,7 @@
ASSERT(range.min >= jumpTable.min);
ASSERT(range.min <= jumpTable.max);
- jumpTable.destinations.append(range.destination);
+ jumpTable.destinations.uncheckedAppend(range.destination);
}
ranges.remove(firstRange, size);
Modified: trunk/Source/WebCore/contentextensions/DFAMinimizer.cpp (209399 => 209400)
--- trunk/Source/WebCore/contentextensions/DFAMinimizer.cpp 2016-12-06 17:18:20 UTC (rev 209399)
+++ trunk/Source/WebCore/contentextensions/DFAMinimizer.cpp 2016-12-06 17:42:37 UTC (rev 209400)
@@ -87,7 +87,7 @@
m_elementPositionInPartitionedNodes[i] = i;
m_elementToSetMap[i] = 0;
}
- m_sets.append(SetDescriptor({ 0, size, 0 }));
+ m_sets.uncheckedAppend(SetDescriptor { 0, size, 0 });
}
void reserveUninitializedCapacity(unsigned elementCount)
Modified: trunk/Source/WebCore/css/StyleProperties.cpp (209399 => 209400)
--- trunk/Source/WebCore/css/StyleProperties.cpp 2016-12-06 17:18:20 UTC (rev 209399)
+++ trunk/Source/WebCore/css/StyleProperties.cpp 2016-12-06 17:42:37 UTC (rev 209400)
@@ -1296,9 +1296,8 @@
Vector<CSSProperty, 256> list;
list.reserveInitialCapacity(length);
for (unsigned i = 0; i < length; ++i) {
- auto value = getPropertyCSSValueInternal(set[i]);
- if (value)
- list.append(CSSProperty(set[i], WTFMove(value), false));
+ if (auto value = getPropertyCSSValueInternal(set[i]))
+ list.uncheckedAppend(CSSProperty(set[i], WTFMove(value), false));
}
return MutableStyleProperties::create(list.data(), list.size());
}
Modified: trunk/Source/WebCore/css/StyleRule.cpp (209399 => 209400)
--- trunk/Source/WebCore/css/StyleRule.cpp 2016-12-06 17:18:20 UTC (rev 209399)
+++ trunk/Source/WebCore/css/StyleRule.cpp 2016-12-06 17:42:37 UTC (rev 209400)
@@ -323,8 +323,8 @@
: StyleRuleBase(o)
{
m_childRules.reserveInitialCapacity(o.m_childRules.size());
- for (unsigned i = 0, size = o.m_childRules.size(); i < size; ++i)
- m_childRules.uncheckedAppend(o.m_childRules[i]->copy());
+ for (auto& childRule : o.m_childRules)
+ m_childRules.uncheckedAppend(childRule->copy());
}
void StyleRuleGroup::wrapperInsertRule(unsigned index, Ref<StyleRuleBase>&& rule)
Modified: trunk/Source/WebCore/css/parser/CSSParserValues.cpp (209399 => 209400)
--- trunk/Source/WebCore/css/parser/CSSParserValues.cpp 2016-12-06 17:18:20 UTC (rev 209399)
+++ trunk/Source/WebCore/css/parser/CSSParserValues.cpp 2016-12-06 17:42:37 UTC (rev 209400)
@@ -410,7 +410,7 @@
auto argumentList = std::make_unique<Vector<AtomicString>>();
argumentList->reserveInitialCapacity(stringVector.size());
for (const AtomicString& languageArgument : stringVector)
- argumentList->append(languageArgument);
+ argumentList->uncheckedAppend(languageArgument);
m_selector->setLangArgumentList(WTFMove(argumentList));
}
Modified: trunk/Source/WebCore/cssjit/SelectorCompiler.cpp (209399 => 209400)
--- trunk/Source/WebCore/cssjit/SelectorCompiler.cpp 2016-12-06 17:18:20 UTC (rev 209399)
+++ trunk/Source/WebCore/cssjit/SelectorCompiler.cpp 2016-12-06 17:42:37 UTC (rev 209400)
@@ -3664,7 +3664,7 @@
for (const NthChildOfSelectorInfo& nthLastChildOfSelectorInfo : fragment.nthLastChildOfFilters) {
if (nthFilterIsAlwaysSatisified(nthLastChildOfSelectorInfo.a, nthLastChildOfSelectorInfo.b))
continue;
- validSubsetFilters.append(&nthLastChildOfSelectorInfo);
+ validSubsetFilters.uncheckedAppend(&nthLastChildOfSelectorInfo);
}
if (validSubsetFilters.isEmpty())
return;
Modified: trunk/Source/WebCore/dom/DocumentMarkerController.cpp (209399 => 209400)
--- trunk/Source/WebCore/dom/DocumentMarkerController.cpp 2016-12-06 17:18:20 UTC (rev 209399)
+++ trunk/Source/WebCore/dom/DocumentMarkerController.cpp 2016-12-06 17:42:37 UTC (rev 209400)
@@ -162,7 +162,7 @@
Vector<FloatRect> absoluteMarkerRects;
absoluteMarkerRects.reserveInitialCapacity(absoluteMarkerQuads.size());
for (const auto& quad : absoluteMarkerQuads)
- absoluteMarkerRects.append(quad.boundingBox());
+ absoluteMarkerRects.uncheckedAppend(quad.boundingBox());
marker.setUnclippedAbsoluteRects(absoluteMarkerRects);
}
Modified: trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.mm (209399 => 209400)
--- trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.mm 2016-12-06 17:18:20 UTC (rev 209399)
+++ trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.mm 2016-12-06 17:42:37 UTC (rev 209400)
@@ -86,7 +86,7 @@
Vector<LayoutUnit> snapOffsets;
snapOffsets.reserveInitialCapacity(snapOffsetsAsFloat.size());
for (auto offset : snapOffsetsAsFloat)
- snapOffsets.append(offset);
+ snapOffsets.uncheckedAppend(offset);
return snapOffsets;
}
Modified: trunk/Source/WebCore/platform/audio/AudioBus.cpp (209399 => 209400)
--- trunk/Source/WebCore/platform/audio/AudioBus.cpp 2016-12-06 17:18:20 UTC (rev 209399)
+++ trunk/Source/WebCore/platform/audio/AudioBus.cpp 2016-12-06 17:42:37 UTC (rev 209400)
@@ -65,7 +65,7 @@
for (unsigned i = 0; i < numberOfChannels; ++i) {
auto channel = allocate ? std::make_unique<AudioChannel>(length) : std::make_unique<AudioChannel>(nullptr, length);
- m_channels.append(WTFMove(channel));
+ m_channels.uncheckedAppend(WTFMove(channel));
}
m_layout = LayoutCanonical; // for now this is the only layout we define
Modified: trunk/Source/WebCore/platform/graphics/FontCache.cpp (209399 => 209400)
--- trunk/Source/WebCore/platform/graphics/FontCache.cpp 2016-12-06 17:18:20 UTC (rev 209399)
+++ trunk/Source/WebCore/platform/graphics/FontCache.cpp 2016-12-06 17:42:37 UTC (rev 209400)
@@ -402,7 +402,7 @@
keysToRemove.reserveInitialCapacity(fontPlatformDataCache().size());
for (auto& entry : fontPlatformDataCache()) {
if (entry.value && !cachedFonts().contains(*entry.value))
- keysToRemove.append(entry.key);
+ keysToRemove.uncheckedAppend(entry.key);
}
for (auto& key : keysToRemove)
fontPlatformDataCache().remove(key);
Modified: trunk/Source/WebCore/platform/graphics/PathUtilities.cpp (209399 => 209400)
--- trunk/Source/WebCore/platform/graphics/PathUtilities.cpp 2016-12-06 17:18:20 UTC (rev 209399)
+++ trunk/Source/WebCore/platform/graphics/PathUtilities.cpp 2016-12-06 17:42:37 UTC (rev 209400)
@@ -277,7 +277,7 @@
}
if (!isContained)
- rectPolygons.append(edgesForRect(rect, graph));
+ rectPolygons.uncheckedAppend(edgesForRect(rect, graph));
}
return unitePolygons(rectPolygons, graph);
}
Modified: trunk/Source/WebCore/platform/mediastream/CaptureDeviceManager.cpp (209399 => 209400)
--- trunk/Source/WebCore/platform/mediastream/CaptureDeviceManager.cpp 2016-12-06 17:18:20 UTC (rev 209399)
+++ trunk/Source/WebCore/platform/mediastream/CaptureDeviceManager.cpp 2016-12-06 17:42:37 UTC (rev 209400)
@@ -96,7 +96,7 @@
sourceUIDs.reserveInitialCapacity(bestSources.size());
std::sort(bestSources.begin(), bestSources.end(), sortBasedOnFitnessScore);
for (auto& device : bestSources)
- sourceUIDs.append(device->persistentID());
+ sourceUIDs.uncheckedAppend(device->persistentID());
return sourceUIDs;
}
Modified: trunk/Source/WebCore/platform/mediastream/RealtimeMediaSource.cpp (209399 => 209400)
--- trunk/Source/WebCore/platform/mediastream/RealtimeMediaSource.cpp 2016-12-06 17:18:20 UTC (rev 209399)
+++ trunk/Source/WebCore/platform/mediastream/RealtimeMediaSource.cpp 2016-12-06 17:42:37 UTC (rev 209400)
@@ -296,7 +296,7 @@
Vector<String> supportedModes;
supportedModes.reserveInitialCapacity(modes.size());
for (auto& mode : modes)
- supportedModes.append(RealtimeMediaSourceSettings::facingMode(mode));
+ supportedModes.uncheckedAppend(RealtimeMediaSourceSettings::facingMode(mode));
return downcast<StringConstraint>(constraint).fitnessDistance(supportedModes);
break;
}
Modified: trunk/Source/WebCore/platform/network/cf/FormDataStreamCFNet.cpp (209399 => 209400)
--- trunk/Source/WebCore/platform/network/cf/FormDataStreamCFNet.cpp 2016-12-06 17:18:20 UTC (rev 209399)
+++ trunk/Source/WebCore/platform/network/cf/FormDataStreamCFNet.cpp 2016-12-06 17:42:37 UTC (rev 209400)
@@ -211,7 +211,7 @@
size_t size = newInfo->formData->elements().size();
newInfo->remainingElements.reserveInitialCapacity(size);
for (size_t i = 0; i < size; ++i)
- newInfo->remainingElements.append(newInfo->formData->elements()[size - i - 1]);
+ newInfo->remainingElements.uncheckedAppend(newInfo->formData->elements()[size - i - 1]);
return newInfo;
}