Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce check argument args allocations #10

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions bytes/src/main/java/org/apache/tuweni/bytes/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,47 @@ static void checkArgument(boolean condition, String message, Object... args) {
throw new IllegalArgumentException(String.format(message, args));
}
}

@FormatMethod
static void checkArgument(boolean condition, String message) {
if (!condition) {
throw new IllegalArgumentException(message);
}
}

@FormatMethod
static void checkArgument(boolean condition, String message, int arg1) {
if (!condition) {
throw new IllegalArgumentException(String.format(message, arg1));
}
}

@FormatMethod
static void checkArgument(boolean condition, String message, int arg1, int arg2) {
if (!condition) {
throw new IllegalArgumentException(String.format(message, arg1, arg2));
}
}

@FormatMethod
static void checkArgument(boolean condition, String message, int arg1, int arg2, int arg3) {
if (!condition) {
throw new IllegalArgumentException(String.format(message, arg1, arg2, arg3));
}
}

@FormatMethod
static void checkArgument(
boolean condition, String message, int arg1, int arg2, int arg3, int arg4) {
if (!condition) {
throw new IllegalArgumentException(String.format(message, arg1, arg2, arg3, arg4));
}
}

@FormatMethod
static void checkArgument(boolean condition, String message, long arg1) {
if (!condition) {
throw new IllegalArgumentException(String.format(message, arg1));
}
}
}
Loading