Title: [250180] trunk/Source
Revision
250180
Author
[email protected]
Date
2019-09-21 04:39:57 -0700 (Sat, 21 Sep 2019)

Log Message

clang-tidy: Fix unnecessary copy/ref churn of for loop variables in WTF/_javascript_Core
<https://webkit.org/b/202069>

Reviewed by Mark Lam.

Fix unwanted copying/ref churn of loop variables by making them
const references.

Source/_javascript_Core:

* bytecode/CodeBlock.cpp:
(JSC::CodeBlock::setConstantIdentifierSetRegisters):
* bytecompiler/BytecodeGenerator.cpp:
(JSC::BytecodeGenerator::prepareLexicalScopeForNextForLoopIteration):
* dfg/DFGGraph.cpp:
(JSC::DFG::Graph::dump):
* inspector/agents/InspectorAgent.cpp:
(Inspector::InspectorAgent::activateExtraDomains):
* inspector/remote/cocoa/RemoteInspectorCocoa.mm:
(Inspector::RemoteInspector::stopInternal):
(Inspector::RemoteInspector::xpcConnectionFailed):
(Inspector::RemoteInspector::pushListingsNow):
* parser/Parser.h:
(JSC::Scope::computeLexicallyCapturedVariablesAndPurgeCandidates):
* runtime/ProxyObject.cpp:
(JSC::ProxyObject::performGetOwnPropertyNames):
* runtime/SamplingProfiler.cpp:
(JSC::SamplingProfiler::registerForReportAtExit):
(JSC::SamplingProfiler::reportTopFunctions):
(JSC::SamplingProfiler::reportTopBytecodes):
* runtime/TypeSet.cpp:
(JSC::StructureShape::inspectorRepresentation):
(JSC::StructureShape::merge):

Source/WTF:

* wtf/AggregateLogger.h:
(WTF::AggregateLogger::log const):

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (250179 => 250180)


--- trunk/Source/_javascript_Core/ChangeLog	2019-09-21 06:37:34 UTC (rev 250179)
+++ trunk/Source/_javascript_Core/ChangeLog	2019-09-21 11:39:57 UTC (rev 250180)
@@ -1,3 +1,37 @@
+2019-09-21  David Kilzer  <[email protected]>
+
+        clang-tidy: Fix unnecessary copy/ref churn of for loop variables in WTF/_javascript_Core
+        <https://webkit.org/b/202069>
+
+        Reviewed by Mark Lam.
+
+        Fix unwanted copying/ref churn of loop variables by making them
+        const references.
+
+        * bytecode/CodeBlock.cpp:
+        (JSC::CodeBlock::setConstantIdentifierSetRegisters):
+        * bytecompiler/BytecodeGenerator.cpp:
+        (JSC::BytecodeGenerator::prepareLexicalScopeForNextForLoopIteration):
+        * dfg/DFGGraph.cpp:
+        (JSC::DFG::Graph::dump):
+        * inspector/agents/InspectorAgent.cpp:
+        (Inspector::InspectorAgent::activateExtraDomains):
+        * inspector/remote/cocoa/RemoteInspectorCocoa.mm:
+        (Inspector::RemoteInspector::stopInternal):
+        (Inspector::RemoteInspector::xpcConnectionFailed):
+        (Inspector::RemoteInspector::pushListingsNow):
+        * parser/Parser.h:
+        (JSC::Scope::computeLexicallyCapturedVariablesAndPurgeCandidates):
+        * runtime/ProxyObject.cpp:
+        (JSC::ProxyObject::performGetOwnPropertyNames):
+        * runtime/SamplingProfiler.cpp:
+        (JSC::SamplingProfiler::registerForReportAtExit):
+        (JSC::SamplingProfiler::reportTopFunctions):
+        (JSC::SamplingProfiler::reportTopBytecodes):
+        * runtime/TypeSet.cpp:
+        (JSC::StructureShape::inspectorRepresentation):
+        (JSC::StructureShape::merge):
+
 2019-09-20  Keith Miller  <[email protected]>
 
         eliding a move in Air O0 needs to mark the dest's old reg as available

Modified: trunk/Source/_javascript_Core/bytecode/CodeBlock.cpp (250179 => 250180)


--- trunk/Source/_javascript_Core/bytecode/CodeBlock.cpp	2019-09-21 06:37:34 UTC (rev 250179)
+++ trunk/Source/_javascript_Core/bytecode/CodeBlock.cpp	2019-09-21 11:39:57 UTC (rev 250180)
@@ -882,7 +882,7 @@
         JSSet* jsSet = JSSet::create(exec, vm, setStructure, set.size());
         RETURN_IF_EXCEPTION(scope, void());
 
-        for (auto setEntry : set) {
+        for (const auto& setEntry : set) {
             JSString* jsString = jsOwnedString(vm, setEntry.get()); 
             jsSet->add(exec, jsString);
             RETURN_IF_EXCEPTION(scope, void());

Modified: trunk/Source/_javascript_Core/bytecompiler/BytecodeGenerator.cpp (250179 => 250180)


--- trunk/Source/_javascript_Core/bytecompiler/BytecodeGenerator.cpp	2019-09-21 06:37:34 UTC (rev 250179)
+++ trunk/Source/_javascript_Core/bytecompiler/BytecodeGenerator.cpp	2019-09-21 11:39:57 UTC (rev 250180)
@@ -2326,7 +2326,7 @@
     move(scopeRegister(), loopScope);
 
     {
-        for (auto pair : activationValuesToCopyOver) {
+        for (const auto& pair : activationValuesToCopyOver) {
             const Identifier& identifier = pair.second;
             SymbolTableEntry entry = symbolTable->get(NoLockingNecessary, identifier.impl());
             RELEASE_ASSERT(!entry.isNull());

Modified: trunk/Source/_javascript_Core/dfg/DFGGraph.cpp (250179 => 250180)


--- trunk/Source/_javascript_Core/dfg/DFGGraph.cpp	2019-09-21 06:37:34 UTC (rev 250179)
+++ trunk/Source/_javascript_Core/dfg/DFGGraph.cpp	2019-09-21 11:39:57 UTC (rev 250180)
@@ -546,7 +546,7 @@
             out.print(prefix, "  Argument formats for entrypoint index: ", entrypointIndex, " : ", listDump(m_argumentFormats[entrypointIndex]), "\n");
     }
     else {
-        for (auto pair : m_rootToArguments)
+        for (const auto& pair : m_rootToArguments)
             out.print(prefix, "  Arguments for block#", pair.key->index, ": ", listDump(pair.value), "\n");
     }
     out.print("\n");

Modified: trunk/Source/_javascript_Core/inspector/agents/InspectorAgent.cpp (250179 => 250180)


--- trunk/Source/_javascript_Core/inspector/agents/InspectorAgent.cpp	2019-09-21 06:37:34 UTC (rev 250179)
+++ trunk/Source/_javascript_Core/inspector/agents/InspectorAgent.cpp	2019-09-21 11:39:57 UTC (rev 250180)
@@ -120,7 +120,7 @@
         return;
 
     auto domainNames = JSON::ArrayOf<String>::create();
-    for (auto domainName : extraDomains)
+    for (const auto& domainName : extraDomains)
         domainNames->addItem(domainName);
 
     m_frontendDispatcher->activateExtraDomains(WTFMove(domainNames));

Modified: trunk/Source/_javascript_Core/inspector/remote/cocoa/RemoteInspectorCocoa.mm (250179 => 250180)


--- trunk/Source/_javascript_Core/inspector/remote/cocoa/RemoteInspectorCocoa.mm	2019-09-21 06:37:34 UTC (rev 250179)
+++ trunk/Source/_javascript_Core/inspector/remote/cocoa/RemoteInspectorCocoa.mm	2019-09-21 11:39:57 UTC (rev 250180)
@@ -239,7 +239,7 @@
 
     m_pushScheduled = false;
 
-    for (auto targetConnection : m_targetConnectionMap.values())
+    for (const auto& targetConnection : m_targetConnectionMap.values())
         targetConnection->close();
     m_targetConnectionMap.clear();
 
@@ -347,7 +347,7 @@
 
     m_pushScheduled = false;
 
-    for (auto targetConnection : m_targetConnectionMap.values())
+    for (const auto& targetConnection : m_targetConnectionMap.values())
         targetConnection->close();
     m_targetConnectionMap.clear();
 
@@ -437,7 +437,7 @@
     m_pushScheduled = false;
 
     RetainPtr<NSMutableDictionary> listings = adoptNS([[NSMutableDictionary alloc] init]);
-    for (RetainPtr<NSDictionary> listing : m_targetListingMap.values()) {
+    for (const auto& listing : m_targetListingMap.values()) {
         NSString *targetIdentifierString = [[listing.get() objectForKey:WIRTargetIdentifierKey] stringValue];
         [listings setObject:listing.get() forKey:targetIdentifierString];
     }

Modified: trunk/Source/_javascript_Core/parser/Parser.h (250179 => 250180)


--- trunk/Source/_javascript_Core/parser/Parser.h	2019-09-21 06:37:34 UTC (rev 250179)
+++ trunk/Source/_javascript_Core/parser/Parser.h	2019-09-21 11:39:57 UTC (rev 250180)
@@ -330,7 +330,7 @@
 
         // We can now purge values from the captured candidates because they're captured in this scope.
         {
-            for (auto entry : m_lexicalVariables) {
+            for (const auto& entry : m_lexicalVariables) {
                 if (entry.value.isCaptured())
                     m_closedVariableCandidates.remove(entry.key.get());
             }

Modified: trunk/Source/_javascript_Core/runtime/ProxyObject.cpp (250179 => 250180)


--- trunk/Source/_javascript_Core/runtime/ProxyObject.cpp	2019-09-21 06:37:34 UTC (rev 250179)
+++ trunk/Source/_javascript_Core/runtime/ProxyObject.cpp	2019-09-21 11:39:57 UTC (rev 250180)
@@ -1056,7 +1056,7 @@
 
     if (!enumerationMode.includeDontEnumProperties()) {
         // Filtering DontEnum properties is observable in proxies and must occur following the invariant checks above.
-        for (auto propertyName : trapResult) {
+        for (const auto& propertyName : trapResult) {
             PropertySlot slot(this, PropertySlot::InternalMethodType::GetOwnProperty);
             auto result = getOwnPropertySlotCommon(exec, propertyName, slot);
             RETURN_IF_EXCEPTION(scope, void());
@@ -1067,7 +1067,7 @@
             propertyNames.add(propertyName.impl());
         }
     } else {
-        for (auto propertyName : trapResult)
+        for (const auto& propertyName : trapResult)
             propertyNames.add(propertyName.impl());
     }
 }

Modified: trunk/Source/_javascript_Core/runtime/SamplingProfiler.cpp (250179 => 250180)


--- trunk/Source/_javascript_Core/runtime/SamplingProfiler.cpp	2019-09-21 06:37:34 UTC (rev 250179)
+++ trunk/Source/_javascript_Core/runtime/SamplingProfiler.cpp	2019-09-21 11:39:57 UTC (rev 250180)
@@ -1013,7 +1013,7 @@
     if (!profilesToReport) {
         profilesToReport = new HashSet<RefPtr<SamplingProfiler>>();
         atexit([]() {
-            for (auto profile : *profilesToReport)
+            for (const auto& profile : *profilesToReport)
                 profile->reportDataToOptionFile();
         });
     }
@@ -1066,7 +1066,7 @@
     auto takeMax = [&] () -> std::pair<String, size_t> {
         String maxFrameDescription;
         size_t maxFrameCount = 0;
-        for (auto entry : functionCounts) {
+        for (const auto& entry : functionCounts) {
             if (entry.value > maxFrameCount) {
                 maxFrameCount = entry.value;
                 maxFrameDescription = entry.key;
@@ -1146,7 +1146,7 @@
     auto takeMax = [&] () -> std::pair<String, size_t> {
         String maxFrameDescription;
         size_t maxFrameCount = 0;
-        for (auto entry : bytecodeCounts) {
+        for (const auto& entry : bytecodeCounts) {
             if (entry.value > maxFrameCount) {
                 maxFrameCount = entry.value;
                 maxFrameDescription = entry.key;

Modified: trunk/Source/_javascript_Core/runtime/TypeSet.cpp (250179 => 250180)


--- trunk/Source/_javascript_Core/runtime/TypeSet.cpp	2019-09-21 06:37:34 UTC (rev 250179)
+++ trunk/Source/_javascript_Core/runtime/TypeSet.cpp	2019-09-21 11:39:57 UTC (rev 250180)
@@ -497,9 +497,9 @@
     while (currentShape) {
         auto fields = JSON::ArrayOf<String>::create();
         auto optionalFields = JSON::ArrayOf<String>::create();
-        for (auto field : currentShape->m_fields)
+        for (const auto& field : currentShape->m_fields)
             fields->addItem(field.get());
-        for (auto field : currentShape->m_optionalFields)
+        for (const auto& field : currentShape->m_optionalFields)
             optionalFields->addItem(field.get());
 
         currentObject->setFields(&fields.get());
@@ -538,7 +538,7 @@
     ASSERT(a->hasSamePrototypeChain(b.get()));
 
     auto merged = StructureShape::create();
-    for (auto field : a->m_fields) {
+    for (const auto& field : a->m_fields) {
         if (b->m_fields.contains(field))
             merged->m_fields.add(field);
         else
@@ -545,7 +545,7 @@
             merged->m_optionalFields.add(field);
     }
 
-    for (auto field : b->m_fields) {
+    for (const auto& field : b->m_fields) {
         if (!merged->m_fields.contains(field)) {
             auto addResult = merged->m_optionalFields.add(field);
             ASSERT_UNUSED(addResult, addResult.isNewEntry);
@@ -552,9 +552,9 @@
         }
     }
 
-    for (auto field : a->m_optionalFields)
+    for (const auto& field : a->m_optionalFields)
         merged->m_optionalFields.add(field);
-    for (auto field : b->m_optionalFields)
+    for (const auto& field : b->m_optionalFields)
         merged->m_optionalFields.add(field);
 
     ASSERT(a->m_constructorName == b->m_constructorName);

Modified: trunk/Source/WTF/ChangeLog (250179 => 250180)


--- trunk/Source/WTF/ChangeLog	2019-09-21 06:37:34 UTC (rev 250179)
+++ trunk/Source/WTF/ChangeLog	2019-09-21 11:39:57 UTC (rev 250180)
@@ -1,3 +1,16 @@
+2019-09-21  David Kilzer  <[email protected]>
+
+        clang-tidy: Fix unnecessary copy/ref churn of for loop variables in WTF/_javascript_Core
+        <https://webkit.org/b/202069>
+
+        Reviewed by Mark Lam.
+
+        Fix unwanted copying/ref churn of loop variables by making them
+        const references.
+
+        * wtf/AggregateLogger.h:
+        (WTF::AggregateLogger::log const):
+
 2019-09-20  Keith Rollin  <[email protected]>
 
         Remove some support for < iOS 13

Modified: trunk/Source/WTF/wtf/AggregateLogger.h (250179 => 250180)


--- trunk/Source/WTF/wtf/AggregateLogger.h	2019-09-21 06:37:34 UTC (rev 250179)
+++ trunk/Source/WTF/wtf/AggregateLogger.h	2019-09-21 11:39:57 UTC (rev 250180)
@@ -104,7 +104,7 @@
 
         Logger::log(channel, level, arguments...);
 
-        for (auto logger : m_loggers) {
+        for (const auto& logger : m_loggers) {
             for (Observer& observer : logger->observers())
                 observer.didLogMessage(channel, level, { ConsoleLogValue<Argument>::toValue(arguments)... });
         }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to