W3C home > Mailing lists > Public > whatwg@whatwg.org > February 2011

[whatwg] Cryptographically strong random numbers

From: Brendan Eich <brendan@mozilla.org>
Date: Mon, 14 Feb 2011 16:47:51 -0800
Message-ID: <7926AE33-E24E-4A45-9B9E-200D67DF4BB7@mozilla.org>
On Feb 14, 2011, at 3:03 PM, Allen Wirfs-Brock wrote:

> And why overwrite the elements of an existing array?  Why not just creating a new Array and use the argument to specify the desired length?

Just to respond to this, I believe the reusable buffer is an optimization (premature? perhaps not for those JS VMs that lack super-fast generational GC) to allow the API user to amortize allocation overhead across many calls to getRandomValues. Of course, with a fast enough GC or few enough calls, this optimization doesn't matter.

The IDL's use of an array inout parameter also supports efficient bindings for languages with stack allocation, which is a non-trivial win in C and C++ not only compared to malloc performance-wise, but also for automated cleanup (vs. intrinsic cost of free, plus on some OSes, "which free do I call"?).

/be
Received on Monday, 14 February 2011 16:47:51 UTC

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 16:59:30 UTC