Skip to content

Commit

Permalink
Implement Objects.checkFromIndexSize
Browse files Browse the repository at this point in the history
  • Loading branch information
gzsombor authored and luben committed Jun 4, 2024
1 parent 7fd6382 commit d349b10
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
13 changes: 13 additions & 0 deletions src/main/java/com/github/luben/zstd/Objects.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.github.luben.zstd;

final class Objects {

/**
* Checks constraints, that the fromIndex, size, length is not negative, and fromIndex + size is not greater than the size.
*/
static void checkFromIndexSize(int fromIndex, int size, int length) {
if ((length | fromIndex | size) < 0 || size > length - fromIndex) {
throw new IndexOutOfBoundsException(String.format("Range [%s, %<s + %s) out of bounds for length %s", fromIndex, size, length));
}
}
}
1 change: 0 additions & 1 deletion src/main/java/com/github/luben/zstd/ZstdCompressCtx.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

import java.nio.ByteBuffer;
import java.util.Arrays;
import java.util.Objects;

public class ZstdCompressCtx extends AutoCloseBase {

Expand Down
1 change: 0 additions & 1 deletion src/main/java/com/github/luben/zstd/ZstdDecompressCtx.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

import java.nio.ByteBuffer;
import java.util.Arrays;
import java.util.Objects;

public class ZstdDecompressCtx extends AutoCloseBase {

Expand Down

0 comments on commit d349b10

Please sign in to comment.