Optimize MappedJournalSegmentWriter.truncate() 66/110566/2
authorRobert Varga <robert.varga@pantheon.tech>
Sat, 9 Mar 2024 13:33:11 +0000 (14:33 +0100)
committerRobert Varga <nite@hq.sk>
Mon, 11 Mar 2024 12:51:11 +0000 (12:51 +0000)
commit5b9d16d22b8645011f8a79167da4d31a46195327
treefae4e784ee67b2f3985cc2bf52fc718242c0e4f9
parent4a74d808e33fef2e002af1acc996b7a2ba228757
Optimize MappedJournalSegmentWriter.truncate()

Reduce code duplication by separating current position manipulation and
entry zero-out.

Also use a single putLong() instead of two putInt()s, eliminating one
range check.

Overall this makes the two implementations much more similar, allowing
sharing code at some later point in the future.

JIRA: CONTROLLER-2095
Change-Id: I9791b5e27a779210b5500a7923ccada7156f26e5
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
atomix-storage/src/main/java/io/atomix/storage/journal/MappedJournalSegmentWriter.java