Repository navigation
Conversation
Test Results 54 files ±0 54 suites ±0 38m 39s ⏱️ +49s For more details on these errors, see this check. Results for commit 95d3227. ± Comparison against base commit a399aac. ♻️ This comment has been updated with latest results. |
7e91b30 to
34d3d1e
Compare
laeubi
left a comment
There was a problem hiding this comment.
Can you please share a numbers here that are attributed to the String#format versus String concatenation? Also its unclear what "this method" means the call you change is not a method but a lamda (where a method would make it much more readable here).
To be honest I doubt we get any noticeable "improvement" here, the SHA-256 and its repeated lookup a few lines below is likely much more expensive than a String.format and this makes an already hard to read construct even harder to read (see my comment).
| String ID = Arrays.stream(bundleContext.getBundles()) | ||
| .map(bundle -> String.format("%d %s %s", bundle.getBundleId(), bundle.getSymbolicName(), //$NON-NLS-1$ | ||
| bundle.getVersion())) | ||
| .map(bundle -> bundle.getBundleId() + " " + bundle.getSymbolicName() + " " + bundle.getVersion()) //$NON-NLS-1$ //$NON-NLS-2$ |
There was a problem hiding this comment.
This is already hard to read, I would suggest to extract it into a method in any case.
|
I wanted to see the effect myself, so I wrote a small plain-Java reproducer (same pipeline: map, sorted, joining, then SHA-256; synthetic bundles; no JMH, so indicative only). Warm (JIT-compiled, 868 bundles):
Even with 10 000 bundles it is ~3 ms vs. ~0.8 ms. Cold (fresh JVM, single call, 868 bundles):
So there is a one-time cost, and my claim that the digest is the bigger part was wrong: both are of similar size. |
|
I'll drop the performance claim from the PR. |
There was a problem hiding this comment.
Having this in a method would likely also improve readability.
34d3d1e to
edac991
Compare
Extract the per-bundle formatting and SHA-256 hashing of getCurrentPlatformState into toStateEntry and hash helper methods, using plain concatenation instead of String.format. The resulting key is unchanged. Assisted-by: multiple AI agents and layers of automated tooling 🤖
edac991 to
95d3227
Compare
Extracts the per-bundle formatting and SHA-256 hashing of
ContentDescriptionManager.getCurrentPlatformStateintotoStateEntryandhashhelper methods, using plain concatenation instead ofString.formatso the stream pipeline and state calculation are easier to read. The resulting key is unchanged, so the persisted content description cache stays valid.