Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .jules/bolt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## 2026-07-01 - Byte Array to Hex String Conversion Optimization
**Learning:** In Java 21, using `String.format("%02x", b)` inside a loop to convert a byte array to a hex string causes unnecessary allocations and is significantly slower than native alternatives.
**Action:** Use `java.util.HexFormat.of().formatHex(bytes)` for faster and allocation-free conversions from byte arrays to hex strings in this codebase.
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,10 @@ private String contentHash(MultipartFile file) {
}

byte[] raw = digest.digest();
StringBuilder hex = new StringBuilder(raw.length * 2);
for (byte b : raw) {
hex.append(String.format("%02x", b));
}

return hex.toString();
// Bolt Performance Optimization:
// Use HexFormat instead of String.format loop for performance.
return java.util.HexFormat.of().formatHex(raw);
} catch (NoSuchAlgorithmException ex) {
throw new IllegalStateException("SHA-256 digest unavailable", ex);
} catch (IOException ex) {
Expand Down