From 7e6ca1809340759679d06061bcf4d65eaeec7537 Mon Sep 17 00:00:00 2001 From: Mark Rotteveel Date: Tue, 31 Oct 2023 11:54:58 +0100 Subject: [PATCH] Get rid of Vector in FBProcedureCall --- .../org/firebirdsql/jdbc/FBProcedureCall.java | 35 ++++++++----------- 1 file changed, 15 insertions(+), 20 deletions(-) diff --git a/src/main/org/firebirdsql/jdbc/FBProcedureCall.java b/src/main/org/firebirdsql/jdbc/FBProcedureCall.java index b77f5d1dd..ea71acb30 100644 --- a/src/main/org/firebirdsql/jdbc/FBProcedureCall.java +++ b/src/main/org/firebirdsql/jdbc/FBProcedureCall.java @@ -18,11 +18,13 @@ */ package org.firebirdsql.jdbc; +import org.firebirdsql.jaybird.util.CollectionUtils; + import java.sql.SQLException; +import java.util.ArrayList; import java.util.Collection; import java.util.List; import java.util.Objects; -import java.util.Vector; import static org.firebirdsql.jdbc.SQLStateConstants.*; @@ -46,8 +48,8 @@ public Object clone() { } } - private static Vector cloneParameters(final Vector parameters) { - final Vector clonedParameters = new Vector<>(parameters.size()); + private static List cloneParameters(final List parameters) { + final List clonedParameters = new ArrayList<>(parameters.size()); for (FBProcedureParam param : parameters) { clonedParameters.add(param != null ? (FBProcedureParam) param.clone() : null); } @@ -55,9 +57,8 @@ private static Vector cloneParameters(final Vector inputParams = new Vector<>(); - private Vector outputParams = new Vector<>(); + private List inputParams = new ArrayList<>(); + private List outputParams = new ArrayList<>(); /** * Get the name of the procedure to be called. @@ -92,10 +93,7 @@ public FBProcedureParam getInputParam(int index) { // ensure that vector has right size // note, index starts with 1 - if (inputParams.size() < index) { - inputParams.setSize(index); - } - + CollectionUtils.growToSize(inputParams, index); inputParams.set(index - 1, result); } @@ -120,7 +118,7 @@ public FBProcedureParam getOutputParam(int index) { * * @return instance of {@link FBProcedureParam}. */ - private FBProcedureParam getParam(Collection params, int index) { + private static FBProcedureParam getParam(Collection params, int index) { for (FBProcedureParam param : params) { if (param != null && param.getIndex() == index) { return param; @@ -180,11 +178,7 @@ public List getOutputParams() { * @param param The parameter to be added */ public void addInputParam(FBProcedureParam param) { - if (inputParams.size() < param.getPosition() + 1) { - inputParams.setSize(param.getPosition() + 1); - } - - inputParams.set(param.getPosition(), param); + addParam(inputParams, param); } /** @@ -194,11 +188,12 @@ public void addInputParam(FBProcedureParam param) { * The parameter to be added */ public void addOutputParam(FBProcedureParam param) { - if (outputParams.size() < param.getPosition() + 1) { - outputParams.setSize(param.getPosition() + 1); - } + addParam(outputParams, param); + } - outputParams.set(param.getPosition(), param); + private static void addParam(List params, FBProcedureParam param) { + CollectionUtils.growToSize(params, param.getPosition() + 1); + params.set(param.getPosition(), param); } /**