sodonnel commented on PR #5364:
URL: https://github.com/apache/ozone/pull/5364#issuecomment-1735960548
I think it would be worth benchmarking this code:
```
while(buffer.hasRemaining()) {
checksum.update(buffer.get());
}
```
vs
```
withCachedBuffer(buffer.capacity(), cachedBuffer -> {
cachedBuffer.put(buffer);
cachedBuffer.flip();
checksum.update(cachedBuffer);
});
```
As if the former may be is as fast as the latter because:
1. The checksum has to be updated byte by byte anyway.
2. It avoids copying the source bytes into a new buffer (cached) and then
applying each byte in turn to the checksum.
If both are the same speed, the former avoid any new allocations.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]