@@ -275,26 +275,23 @@ void Hash::OneShotDigest(const FunctionCallbackInfo<Value>& args) {
275
275
}
276
276
277
277
DataPointer output = ([&]() -> DataPointer {
278
- Utf8Value utf8 (isolate, args[3 ]);
279
- ncrypto::Buffer<const unsigned char > buf;
280
278
if (args[3 ]->IsString ()) {
281
- buf = {
279
+ Utf8Value utf8 (isolate, args[3 ]);
280
+ ncrypto::Buffer<const unsigned char > buf = {
282
281
.data = reinterpret_cast <const unsigned char *>(utf8.out ()),
283
282
.len = utf8.length (),
284
283
};
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);
295
286
}
296
287
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);
298
295
})();
299
296
300
297
if (!output) [[unlikely]] {
0 commit comments