mirror of
https://github.com/pbatard/rufus.git
synced 2025-05-23 03:06:56 -04:00
[checksum] use multiple threads and double buffering
* Can reduce the duration of checksum computations by about 1/3rd, if you have quad core CPU or better.
This commit is contained in:
parent
bab3453f4d
commit
e6d3653cac
5 changed files with 185 additions and 33 deletions
|
@ -21,6 +21,7 @@
|
|||
#include <commctrl.h>
|
||||
#include <shlobj.h>
|
||||
#include <wininet.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#pragma once
|
||||
|
||||
|
@ -44,6 +45,21 @@
|
|||
#define bswap_uint16 __builtin_bswap16
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Nibbled from https://github.com/hanji/popcnt/blob/master/populationcount.cpp
|
||||
* Since MSVC x86_32 does not have intrinsic popcount64 and I don't have all day
|
||||
*/
|
||||
static inline int popcnt64(register uint64_t u)
|
||||
{
|
||||
u = (u & 0x5555555555555555) + ((u >> 1) & 0x5555555555555555);
|
||||
u = (u & 0x3333333333333333) + ((u >> 2) & 0x3333333333333333);
|
||||
u = (u & 0x0f0f0f0f0f0f0f0f) + ((u >> 4) & 0x0f0f0f0f0f0f0f0f);
|
||||
u = (u & 0x00ff00ff00ff00ff) + ((u >> 8) & 0x00ff00ff00ff00ff);
|
||||
u = (u & 0x0000ffff0000ffff) + ((u >> 16) & 0x0000ffff0000ffff);
|
||||
u = (u & 0x00000000ffffffff) + ((u >> 32) & 0x00000000ffffffff);
|
||||
return (int)u;
|
||||
}
|
||||
|
||||
static __inline void *_reallocf(void *ptr, size_t size) {
|
||||
void *ret = realloc(ptr, size);
|
||||
if (!ret)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue