Remove last SampleQueue.release allocation

By making AllocationNode fields non-final

PiperOrigin-RevId: 422403816
This commit is contained in:
aquilescanta 2022-01-17 20:44:53 +00:00 committed by Ian Baker
parent ace1988a35
commit f9170b89c4

View File

@ -66,7 +66,7 @@ import java.util.Arrays;
/** Clears all sample data. */
public void reset() {
clearAllocationNodes(firstAllocationNode);
firstAllocationNode = new AllocationNode(0, allocationLength);
firstAllocationNode.reset(/* startPosition= */ 0, allocationLength);
readAllocationNode = firstAllocationNode;
writeAllocationNode = firstAllocationNode;
totalBytesWritten = 0;
@ -462,9 +462,9 @@ import java.util.Arrays;
private static final class AllocationNode implements Allocator.AllocationNode {
/** The absolute position of the start of the data (inclusive). */
public final long startPosition;
public long startPosition;
/** The absolute position of the end of the data (exclusive). */
public final long endPosition;
public long endPosition;
/**
* The {@link Allocation}, or {@code null} if the node is not {@link #initialize initialized}.
*/
@ -481,6 +481,17 @@ import java.util.Arrays;
* initialized.
*/
public AllocationNode(long startPosition, int allocationLength) {
reset(startPosition, allocationLength);
}
/**
* Sets the {@link #startPosition} and the {@link Allocation} length.
*
* <p>Must only be called for uninitialized instances, where {@link #allocation} is {@code
* null}.
*/
public void reset(long startPosition, int allocationLength) {
Assertions.checkState(allocation == null);
this.startPosition = startPosition;
this.endPosition = startPosition + allocationLength;
}