RFR: 8355481: Clean up MHN_copyOutBootstrapArguments
Johan Sjölen
jsjolen at openjdk.org
Thu Apr 24 12:14:07 UTC 2025
Hi,
I'd like to integrate this simplification of the code for this loop.
We used to have:
```c++
if (start < 0) {
for (int pseudo_index = -4; pseudo_index < 0; pseudo_index++) {
if (start == pseudo_index) {
if (start >= end || 0 > pos || pos >= buf->length()) break;
// ...
}
start++;
}
}
That's exactly the same as:
int min_end = MIN2(0, end);
while (-4 <= start && start < min_end) {
if (pos >= buf->length()) break;
// ...
start++;
}
but the latter looks like a conventional loop.
I'd consider this a basic cleanup, which is worth doing in the name of maintainability.
I would have liked to change the `-4` to `-1` into actual names, but I've no clue where those come from. It doesn't seem worth it to change them if they just happen to be a kludge relying on internal details, or something like that.
Testing: GHA Tier1
-------------
Commit messages:
- Separate it
- Clarify our behavior
- We can throw earlier in case of a bad call
- Remove redundant case
- Simplify the code a little bit
Changes: https://git.openjdk.org/jdk/pull/24825/files
Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=24825&range=00
Issue: https://bugs.openjdk.org/browse/JDK-8355481
Stats: 91 lines in 1 file changed: 47 ins; 41 del; 3 mod
Patch: https://git.openjdk.org/jdk/pull/24825.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/24825/head:pull/24825
PR: https://git.openjdk.org/jdk/pull/24825
More information about the hotspot-dev
mailing list