[libcxx-commits] [PATCH] D125702: Refine comments.

Laramie Leavitt via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Mon May 16 09:59:45 PDT 2022


laramiel created this revision.
Herald added a project: All.
laramiel requested review of this revision.
Herald added a project: libc++.
Herald added a subscriber: libcxx-commits.
Herald added a reviewer: libc++.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D125702

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,23 +109,24 @@
             __first[__q] += __r;
             __first[0] = __r;
         }
+        // initialize {(__k + x) % __n} indexing terms
         size_t __kmodn = 0;          // __k % __n
+        size_t __k1modn = __n - 1;   // (__k - 1) % __n
         size_t __kpmodn = __p % __n; // (__k + __p) % __n
         size_t __kqmodn = __q % __n; // (__k + __q) % __n
-        size_t __km1modn = __n - 1;  // (__k-1) % __n
 
         for (size_t __k = 1; __k <= __s; ++__k)
         {
           if (++__kmodn == __n)
             __kmodn = 0;
-          if (++__km1modn == __n)
-            __km1modn = 0;
+          if (++__k1modn == __n)
+            __k1modn = 0;
           if (++__kpmodn == __n)
             __kpmodn = 0;
           if (++__kqmodn == __n)
             __kqmodn = 0;
 
-          result_type __r = 1664525 * _Tp(__first[__kmodn] ^ __first[__kpmodn] ^ __first[__km1modn]);
+          result_type __r = 1664525 * _Tp(__first[__kmodn] ^ __first[__kpmodn] ^ __first[__k1modn]);
           __first[__kpmodn] += __r;
           __r += __kmodn + __v_[__k - 1];
           __first[__kqmodn] += __r;
@@ -135,14 +136,14 @@
         {
           if (++__kmodn == __n)
             __kmodn = 0;
-          if (++__km1modn == __n)
-            __km1modn = 0;
+          if (++__k1modn == __n)
+            __k1modn = 0;
           if (++__kpmodn == __n)
             __kpmodn = 0;
           if (++__kqmodn == __n)
             __kqmodn = 0;
 
-          result_type __r = 1664525 * _Tp(__first[__kmodn] ^ __first[__kpmodn] ^ __first[__km1modn]);
+          result_type __r = 1664525 * _Tp(__first[__kmodn] ^ __first[__kpmodn] ^ __first[__k1modn]);
           __first[__kpmodn] += __r;
           __r += __kmodn;
           __first[__kqmodn] += __r;
@@ -152,14 +153,14 @@
         {
           if (++__kmodn == __n)
             __kmodn = 0;
-          if (++__km1modn == __n)
-            __km1modn = 0;
+          if (++__k1modn == __n)
+            __k1modn = 0;
           if (++__kpmodn == __n)
             __kpmodn = 0;
           if (++__kqmodn == __n)
             __kqmodn = 0;
 
-          result_type __r = 1566083941 * _Tp(__first[__kmodn] + __first[__kpmodn] + __first[__km1modn]);
+          result_type __r = 1566083941 * _Tp(__first[__kmodn] + __first[__kpmodn] + __first[__k1modn]);
           __first[__kpmodn] ^= __r;
           __r -= __kmodn;
           __first[__kqmodn] ^= __r;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D125702.429753.patch
Type: text/x-patch
Size: 2612 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20220516/0e35bd52/attachment.bin>


More information about the libcxx-commits mailing list