1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2024-12-15 04:30:29 +00:00

Use Java 16 ByteBuffer methods where possible

This commit is contained in:
Jonathan Coates 2021-12-18 11:34:44 +00:00
parent 05da4dd362
commit 2f6ad00764
No known key found for this signature in database
GPG Key ID: B9E431FF07C98D06
2 changed files with 3 additions and 6 deletions

View File

@ -106,7 +106,8 @@ class DfpwmStream implements AudioStream
if( head == null ) break; if( head == null ) break;
int toRead = Math.min( head.remaining(), result.remaining() ); int toRead = Math.min( head.remaining(), result.remaining() );
result.put( head.array(), head.position(), toRead ); // TODO: In 1.17 convert this to a ByteBuffer override result.put( result.position(), head, head.position(), toRead );
result.position( result.position() + toRead );
head.position( head.position() + toRead ); head.position( head.position() + toRead );
if( head.hasRemaining() ) break; if( head.hasRemaining() ) break;

View File

@ -53,10 +53,6 @@ public class FileSlice
return; return;
} }
ByteBuffer other = file.duplicate(); file.put( offset, bytes, bytes.position(), bytes.remaining() );
other.position( offset ); // TODO: In 1.17 we can use a separate put(idx, _) method.
other.put( bytes );
if( bytes.remaining() != 0 ) throw new IllegalStateException( "Should have read the whole buffer" );
} }
} }