4 ms·
You have to allocate memory and free it. Interestingly, when reading Raymond Chen's article I thought "reservoir sampling would compare the random number (betw
by bonzini 6d ago
You have to allocate memory and free it.
Interestingly, when reading Raymond Chen's article I thought "reservoir sampling would compare the random number (between 1 and n) to 1, not to n, because that extends more easily to picking more than one element" - and that's what the actual Windows code uses.
- Sopel 6d agoyes, you would have to allocate space for up to 100 file paths, but the article says > it’s more efficient because it reduces the amount of calls into the file system, which is where the bottleneck is Upon reading it a few times I think the article is alluding to a crappy two-pass solution where you don't store a filename but instead an index into a directory, which is flawed anyway due to being racy.