Title: [217149] trunk/Source/_javascript_Core
Revision
217149
Author
fpi...@apple.com
Date
2017-05-19 14:08:42 -0700 (Fri, 19 May 2017)

Log Message

Deduplicate some code in arrayProtoPrivateFuncConcatMemcpy
https://bugs.webkit.org/show_bug.cgi?id=172382

Reviewed by Saam Barati.
        
This is just a small clean-up - my last patch here created some unnecessary code duplication.

* runtime/ArrayPrototype.cpp:
(JSC::arrayProtoPrivateFuncConcatMemcpy):

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (217148 => 217149)


--- trunk/Source/_javascript_Core/ChangeLog	2017-05-19 20:47:44 UTC (rev 217148)
+++ trunk/Source/_javascript_Core/ChangeLog	2017-05-19 21:08:42 UTC (rev 217149)
@@ -1,5 +1,17 @@
 2017-05-19  Filip Pizlo  <fpi...@apple.com>
 
+        Deduplicate some code in arrayProtoPrivateFuncConcatMemcpy
+        https://bugs.webkit.org/show_bug.cgi?id=172382
+
+        Reviewed by Saam Barati.
+        
+        This is just a small clean-up - my last patch here created some unnecessary code duplication.
+
+        * runtime/ArrayPrototype.cpp:
+        (JSC::arrayProtoPrivateFuncConcatMemcpy):
+
+2017-05-19  Filip Pizlo  <fpi...@apple.com>
+
         arrayProtoPrivateFuncConcatMemcpy needs to be down with firstArray being undecided
         https://bugs.webkit.org/show_bug.cgi?id=172369
 

Modified: trunk/Source/_javascript_Core/runtime/ArrayPrototype.cpp (217148 => 217149)


--- trunk/Source/_javascript_Core/runtime/ArrayPrototype.cpp	2017-05-19 20:47:44 UTC (rev 217148)
+++ trunk/Source/_javascript_Core/runtime/ArrayPrototype.cpp	2017-05-19 21:08:42 UTC (rev 217149)
@@ -1318,18 +1318,19 @@
         memcpy(buffer + firstArraySize, secondButterfly->contiguousDouble().data(), sizeof(JSValue) * secondArraySize);
     } else if (type != ArrayWithUndecided) {
         WriteBarrier<Unknown>* buffer = result->butterfly()->contiguous().data();
-        if (firstType != ArrayWithUndecided)
-            memcpy(buffer, firstButterfly->contiguous().data(), sizeof(JSValue) * firstArraySize);
-        else {
-            for (unsigned i = firstArraySize; i--;)
-                buffer[i].clear();
-        }
-        if (secondType != ArrayWithUndecided)
-            memcpy(buffer + firstArraySize, secondButterfly->contiguous().data(), sizeof(JSValue) * secondArraySize);
-        else {
-            for (unsigned i = secondArraySize; i--;)
-                buffer[i + firstArraySize].clear();
-        }
+        
+        auto copy = [&] (unsigned offset, void* source, unsigned size, IndexingType type) {
+            if (type != ArrayWithUndecided) {
+                memcpy(buffer + offset, source, sizeof(JSValue) * size);
+                return;
+            }
+            
+            for (unsigned i = size; i--;)
+                buffer[i + offset].clear();
+        };
+        
+        copy(0, firstButterfly->contiguous().data(), firstArraySize, firstType);
+        copy(firstArraySize, secondButterfly->contiguous().data(), secondArraySize, secondType);
     }
 
     result->butterfly()->setPublicLength(resultSize);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to