[libcxx-commits] [PATCH] D67273: [libc++] Remove unnecessary assignment in exclusive_scan

Louis Dionne via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Tue Dec 1 09:50:05 PST 2020


This revision was not accepted when it landed; it landed in state "Needs Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc30d5101f14f: [libc++] Optimize the number of assignments in std::exclusive_scan (authored by ldionne).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D67273/new/

https://reviews.llvm.org/D67273

Files:
  libcxx/include/numeric


Index: libcxx/include/numeric
===================================================================
--- libcxx/include/numeric
+++ libcxx/include/numeric
@@ -335,14 +335,17 @@
 {
     if (__first != __last)
     {
-        _Tp __saved = __init;
-        do
+        _Tp __tmp(__b(__init, *__first));
+        while (true)
         {
-            __init = __b(__init, *__first);
-            *__result = __saved;
-            __saved = __init;
+            *__result = _VSTD::move(__init);
             ++__result;
-        } while (++__first != __last);
+            ++__first;
+            if (__first == __last)
+                break;
+            __init = _VSTD::move(__tmp);
+            __tmp = __b(__init, *__first);
+        }
     }
     return __result;
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D67273.308692.patch
Type: text/x-patch
Size: 765 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20201201/773f4f09/attachment.bin>


More information about the libcxx-commits mailing list