@@ -134,46 +134,52 @@ VOID WHAPI WHInitEx( PWHCTXEX pContext )
134134VOID 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
0 commit comments