@@ -275,26 +275,23 @@ void Hash::OneShotDigest(const FunctionCallbackInfo<Value>& args) {
275275 }
276276
277277 DataPointer output = ([&]() -> DataPointer {
278- Utf8Value utf8 (isolate, args[3 ]);
279- ncrypto::Buffer<const unsigned char > buf;
280278 if (args[3 ]->IsString ()) {
281- buf = {
279+ Utf8Value utf8 (isolate, args[3 ]);
280+ ncrypto::Buffer<const unsigned char > buf = {
282281 .data = reinterpret_cast <const unsigned char *>(utf8.out ()),
283282 .len = utf8.length (),
284283 };
285- } else {
286- ArrayBufferViewContents<unsigned char > input (args[3 ]);
287- buf = {
288- .data = reinterpret_cast <const unsigned char *>(input.data ()),
289- .len = input.length (),
290- };
291- }
292-
293- if (is_xof) {
294- return ncrypto::xofHashDigest (buf, md, output_length);
284+ return is_xof ? ncrypto::xofHashDigest (buf, md, output_length)
285+ : ncrypto::hashDigest (buf, md);
295286 }
296287
297- return ncrypto::hashDigest (buf, md);
288+ ArrayBufferViewContents<unsigned char > input (args[3 ]);
289+ ncrypto::Buffer<const unsigned char > buf = {
290+ .data = reinterpret_cast <const unsigned char *>(input.data ()),
291+ .len = input.length (),
292+ };
293+ return is_xof ? ncrypto::xofHashDigest (buf, md, output_length)
294+ : ncrypto::hashDigest (buf, md);
298295 })();
299296
300297 if (!output) [[unlikely]] {
0 commit comments