@@ -274,26 +274,23 @@ void Hash::OneShotDigest(const FunctionCallbackInfo<Value>& args) {
|
274 | 274 | } |
275 | 275 | |
276 | 276 | DataPointer output = ([&]() -> DataPointer { |
277 | | - Utf8Value utf8(isolate, args[3]); |
278 | | - ncrypto::Buffer<const unsigned char> buf; |
279 | 277 | if (args[3]->IsString()) { |
280 | | - buf = { |
| 278 | + Utf8Value utf8(isolate, args[3]); |
| 279 | + ncrypto::Buffer<const unsigned char> buf = { |
281 | 280 | .data = reinterpret_cast<const unsigned char*>(utf8.out()), |
282 | 281 | .len = utf8.length(), |
283 | 282 | }; |
284 | | - } else { |
285 | | - ArrayBufferViewContents<unsigned char> input(args[3]); |
286 | | - buf = { |
287 | | - .data = reinterpret_cast<const unsigned char*>(input.data()), |
288 | | - .len = input.length(), |
289 | | - }; |
290 | | - } |
291 | | - |
292 | | -if (is_xof) { |
293 | | -return ncrypto::xofHashDigest(buf, md, output_length); |
| 283 | +return is_xof ? ncrypto::xofHashDigest(buf, md, output_length) |
| 284 | + : ncrypto::hashDigest(buf, md); |
294 | 285 | } |
295 | 286 | |
296 | | -return ncrypto::hashDigest(buf, md); |
| 287 | + ArrayBufferViewContents<unsigned char> input(args[3]); |
| 288 | + ncrypto::Buffer<const unsigned char> buf = { |
| 289 | + .data = reinterpret_cast<const unsigned char*>(input.data()), |
| 290 | + .len = input.length(), |
| 291 | + }; |
| 292 | +return is_xof ? ncrypto::xofHashDigest(buf, md, output_length) |
| 293 | + : ncrypto::hashDigest(buf, md); |
297 | 294 | })(); |
298 | 295 | |
299 | 296 | if (!output) [[unlikely]] { |
|