Skip to content

Commit 5ad9575

Browse files
committed
Small improvement of size handling.
1 parent e0e449b commit 5ad9575

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

byte-buddy-dep/src/main/java/net/bytebuddy/description/method/ParameterList.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -235,9 +235,10 @@ public static ParameterList<ParameterDescription.InDefinedShape> of(Method metho
235235
* {@inheritDoc}
236236
*/
237237
public int size() {
238+
int size = this.size;
238239
if (size == 0) {
239-
int size = EXECUTABLE.getParameterCount(executable);
240-
this.size = size == 0 ? -1 : size;
240+
int actual = EXECUTABLE.getParameterCount(executable);
241+
this.size = size = actual == 0 ? -1 : actual;
241242
}
242243
return size == -1 ? 0 : size;
243244
}
@@ -616,9 +617,10 @@ public ParameterDescription.InGenericShape get(int index) {
616617
* {@inheritDoc}
617618
*/
618619
public int size() {
620+
int size = this.size;
619621
if (size == 0) {
620-
int size = parameterDescriptions.size();
621-
this.size = size == 0 ? -1 : size;
622+
int actual = parameterDescriptions.size();
623+
this.size = size = actual == 0 ? -1 : actual;
622624
}
623625
return size == -1 ? 0 : size;
624626
}

0 commit comments

Comments
 (0)