Skip to content

Commit

Permalink
Prevent unnecessary parameter array allocations
Browse files Browse the repository at this point in the history
We only need to actually allocate the object array that will hold
the Resource method parameters if that method actually has
parameters

(cherry picked from commit a1a4e73)
  • Loading branch information
geoand authored and gsmet committed May 18, 2022
1 parent c97aee4 commit 1b4086d
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ public void restart(RuntimeResource target) {
public void restart(RuntimeResource target, boolean setLocatorTarget) {
this.handlers = target.getHandlerChain();
position = 0;
parameters = new Object[target.getParameterTypes().length];
parameters = target.getParameterTypes().length == 0 ? EMPTY_ARRAY : new Object[target.getParameterTypes().length];
if (setLocatorTarget) {
previousResource = new PreviousResource(this.target, pathParamValues, previousResource);
}
Expand Down Expand Up @@ -646,7 +646,7 @@ protected void requestScopeDeactivated() {

@Override
protected void restarted(boolean keepTarget) {
parameters = new Object[0];
parameters = EMPTY_ARRAY;
if (!keepTarget) {
target = null;
}
Expand Down

0 comments on commit 1b4086d

Please sign in to comment.