[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
Mon May 16 09:50:24 PDT 2022


laramiel added inline comments.


================
Comment at: libcxx/include/__random/seed_seq.h:112
         }
+        size_t __kmodn = 0;          // __k % __n
+        size_t __kpmodn = __p % __n; // (__k + __p) % __n
----------------
Mordante wrote:
> This is a kind of clever code which isn't really obvious. Can you add a bit more comment what it exactly does. After you did that the `__k % __n` comment becomes clear.
The comments that I added worked to make it clear to me while reading [rand.util.seedseq].
What specific comment would make it more clear to you?


================
Comment at: libcxx/include/__random/seed_seq.h:151
         }
         for (size_t __k = __m; __k < __m + __n; ++__k)
         {
----------------
Mordante wrote:
> I think here we can add some comment too. The modulo in this loop works when `__k == __m`, which is true when `__s + 1 <= __m`.
What comment do you think helps? I think that the modulo pattern is pretty clear, particularly since it mirrors the first loop.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125329



More information about the libcxx-commits mailing list