[libcxx-commits] [PATCH] D125329: Replace modulus operations in std::seed_seq::generate with conditional checks.

Laramie Leavitt via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Fri May 20 10:26:13 PDT 2022


laramiel updated this revision to Diff 431005.
laramiel added a comment.

Updating D125329 <https://reviews.llvm.org/D125329>: Update comment on loop.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125329

Files:
  libcxx/include/__random/seed_seq.h


Index: libcxx/include/__random/seed_seq.h
===================================================================
--- libcxx/include/__random/seed_seq.h
+++ libcxx/include/__random/seed_seq.h
@@ -109,7 +109,8 @@
             __first[__q] += __r;
             __first[0] = __r;
         }
-        // initialize {(__k + x) % __n} indexing terms
+        // Initialize indexing terms used with if statements as an optimization to
+        // avoid calculating modulo n on every loop iteration for each term.
         size_t __kmodn = 0;          // __k % __n
         size_t __k1modn = __n - 1;   // (__k - 1) % __n
         size_t __kpmodn = __p % __n; // (__k + __p) % __n


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D125329.431005.patch
Type: text/x-patch
Size: 669 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20220520/ac626d8c/attachment.bin>


More information about the libcxx-commits mailing list