Skip to content

Commit f046b97

Browse files
committed
disable multithreading for very small files
1 parent 5363770 commit f046b97

File tree

4 files changed

+40
-34
lines changed

4 files changed

+40
-34
lines changed

installer/HashCheck.nsi

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,15 @@ FunctionEnd
5353
!insertmacro MUI_LANGUAGE "Ukrainian"
5454
!insertmacro MUI_LANGUAGE "Catalan"
5555

56-
VIProductVersion "2.3.2.11"
56+
VIProductVersion "2.3.2.12"
5757
VIAddVersionKey /LANG=${LANG_ENGLISH} "ProductName" "HashCheck Shell Extension"
58-
VIAddVersionKey /LANG=${LANG_ENGLISH} "ProductVersion" "2.3.2.11"
58+
VIAddVersionKey /LANG=${LANG_ENGLISH} "ProductVersion" "2.3.2.12"
5959
VIAddVersionKey /LANG=${LANG_ENGLISH} "Comments" "Installer distributed from https://github.com/gurnec/HashCheck/releases"
6060
VIAddVersionKey /LANG=${LANG_ENGLISH} "CompanyName" ""
6161
VIAddVersionKey /LANG=${LANG_ENGLISH} "LegalTrademarks" ""
6262
VIAddVersionKey /LANG=${LANG_ENGLISH} "LegalCopyright" "Copyright © Kai Liu, Christopher Gurnee, Tim Schlueter. All rights reserved."
6363
VIAddVersionKey /LANG=${LANG_ENGLISH} "FileDescription" "Installer (x86/x64) from https://github.com/gurnec/HashCheck/releases"
64-
VIAddVersionKey /LANG=${LANG_ENGLISH} "FileVersion" "2.3.2.11"
64+
VIAddVersionKey /LANG=${LANG_ENGLISH} "FileVersion" "2.3.2.12"
6565

6666
; With solid compression, files that are required before the
6767
; actual installation should be stored first in the data block,

libs/WinHash.cpp

Lines changed: 34 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -134,46 +134,52 @@ VOID WHAPI WHInitEx( PWHCTXEX pContext )
134134
VOID WHAPI WHUpdateEx( PWHCTXEX pContext, PCBYTE pbIn, UINT cbIn )
135135
{
136136
#if _MSC_VER >= 1600
137-
auto task_WHUpdateSHA512 = concurrency::make_task([&] { WHUpdateSHA512(&pContext->ctxSHA512, pbIn, cbIn); } );
138-
auto task_WHUpdateSHA256 = concurrency::make_task([&] { WHUpdateSHA256(&pContext->ctxSHA256, pbIn, cbIn); } );
139-
auto task_WHUpdateSHA1 = concurrency::make_task([&] { WHUpdateSHA1 (&pContext->ctxSHA1, pbIn, cbIn); } );
140-
auto task_WHUpdateMD5 = concurrency::make_task([&] { WHUpdateMD5 (&pContext->ctxMD5, pbIn, cbIn); } );
141-
auto task_WHUpdateCRC32 = concurrency::make_task([&] { WHUpdateCRC32 (&pContext->ctxCRC32, pbIn, cbIn); } );
137+
if (cbIn > 384u) { // determined experimentally--smaller than this and multithreading doesn't help, but ymmv
142138

143-
concurrency::structured_task_group hashing_task_group;
139+
auto task_WHUpdateSHA512 = concurrency::make_task([&] { WHUpdateSHA512(&pContext->ctxSHA512, pbIn, cbIn); } );
140+
auto task_WHUpdateSHA256 = concurrency::make_task([&] { WHUpdateSHA256(&pContext->ctxSHA256, pbIn, cbIn); } );
141+
auto task_WHUpdateSHA1 = concurrency::make_task([&] { WHUpdateSHA1 (&pContext->ctxSHA1, pbIn, cbIn); } );
142+
auto task_WHUpdateMD5 = concurrency::make_task([&] { WHUpdateMD5 (&pContext->ctxMD5, pbIn, cbIn); } );
143+
auto task_WHUpdateCRC32 = concurrency::make_task([&] { WHUpdateCRC32 (&pContext->ctxCRC32, pbIn, cbIn); } );
144144

145-
if (pContext->flags & WHEX_CHECKSHA512)
146-
hashing_task_group.run(task_WHUpdateSHA512);
145+
concurrency::structured_task_group hashing_task_group;
147146

148-
if (pContext->flags & WHEX_CHECKSHA256)
149-
hashing_task_group.run(task_WHUpdateSHA256);
147+
if (pContext->flags & WHEX_CHECKSHA512)
148+
hashing_task_group.run(task_WHUpdateSHA512);
150149

151-
if (pContext->flags & WHEX_CHECKSHA1)
152-
hashing_task_group.run(task_WHUpdateSHA1);
150+
if (pContext->flags & WHEX_CHECKSHA256)
151+
hashing_task_group.run(task_WHUpdateSHA256);
153152

154-
if (pContext->flags & WHEX_CHECKMD5)
155-
hashing_task_group.run(task_WHUpdateMD5);
153+
if (pContext->flags & WHEX_CHECKSHA1)
154+
hashing_task_group.run(task_WHUpdateSHA1);
156155

157-
if (pContext->flags & WHEX_CHECKCRC32)
158-
hashing_task_group.run(task_WHUpdateCRC32);
156+
if (pContext->flags & WHEX_CHECKMD5)
157+
hashing_task_group.run(task_WHUpdateMD5);
159158

160-
hashing_task_group.wait();
159+
if (pContext->flags & WHEX_CHECKCRC32)
160+
hashing_task_group.run(task_WHUpdateCRC32);
161161

162-
#else
163-
if (pContext->flags & WHEX_CHECKCRC32)
164-
WHUpdateCRC32(&pContext->ctxCRC32, pbIn, cbIn);
162+
hashing_task_group.wait();
163+
}
165164

166-
if (pContext->flags & WHEX_CHECKMD5)
167-
WHUpdateMD5(&pContext->ctxMD5, pbIn, cbIn);
165+
else {
166+
#endif
167+
if (pContext->flags & WHEX_CHECKCRC32)
168+
WHUpdateCRC32(&pContext->ctxCRC32, pbIn, cbIn);
168169

169-
if (pContext->flags & WHEX_CHECKSHA1)
170-
WHUpdateSHA1(&pContext->ctxSHA1, pbIn, cbIn);
170+
if (pContext->flags & WHEX_CHECKMD5)
171+
WHUpdateMD5(&pContext->ctxMD5, pbIn, cbIn);
171172

172-
if (pContext->flags & WHEX_CHECKSHA256)
173-
WHUpdateSHA256(&pContext->ctxSHA256, pbIn, cbIn);
173+
if (pContext->flags & WHEX_CHECKSHA1)
174+
WHUpdateSHA1(&pContext->ctxSHA1, pbIn, cbIn);
174175

175-
if (pContext->flags & WHEX_CHECKSHA512)
176-
WHUpdateSHA512(&pContext->ctxSHA512, pbIn, cbIn);
176+
if (pContext->flags & WHEX_CHECKSHA256)
177+
WHUpdateSHA256(&pContext->ctxSHA256, pbIn, cbIn);
178+
179+
if (pContext->flags & WHEX_CHECKSHA512)
180+
WHUpdateSHA512(&pContext->ctxSHA512, pbIn, cbIn);
181+
#if _MSC_VER >= 1600
182+
}
177183
#endif
178184
}
179185

license.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
HashCheck Shell Extension
22

33
Copyright (C) 2008-2009 Kai Liu. All rights reserved.
4-
Copyright (C) 2014 Christopher Gurnee. All rights reserved.
4+
Copyright (C) 2014, 2016 Christopher Gurnee. All rights reserved.
55
Copyright (C) 2014 Software Development Laboratories ("Fish" (David B. Trout))
66
Copyright (C) 2016 Tim Schlueter. All rights reserved.
77

version.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@
1212
#define HASHCHECK_NAME_STR "HashCheck Shell Extension"
1313

1414
// Full version: MUST be in the form of major,minor,revision,build
15-
#define HASHCHECK_VERSION_FULL 2,3,2,11
15+
#define HASHCHECK_VERSION_FULL 2,3,2,12
1616

1717
// String version: May be any suitable string
18-
#define HASHCHECK_VERSION_STR "2.3.2.11"
18+
#define HASHCHECK_VERSION_STR "2.3.2.12"
1919

2020
#ifdef _USRDLL
2121
// PE version: MUST be in the form of major.minor

0 commit comments

Comments
 (0)