Skip to content

Commit

Permalink
Some methods used the toArray() method of a collection derived class,…
Browse files Browse the repository at this point in the history
… and passed in a zero-length prototype array argument. It is more efficient to use myCollection.toArray(new Foo[myCollection.size()]) If the array passed in is big enough to store all of the elements of the collection, then it is populated and returned directly. This avoids the need to create a second array (by reflection) to return as the result.
  • Loading branch information
Christopher Barham committed Jul 14, 2012
1 parent a6e547f commit 792ab2f
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions jpos/src/main/java/org/jpos/security/BaseSMAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ public EncryptedPIN generatePIN(String accountNumber, int pinLen, List<String> e
cmdParameters.add(new SimpleMsg("parameter", "Excluded PINs list", excludes));

LogEvent evt = new LogEvent(this, "s-m-operation");
evt.addMessage(new SimpleMsg("command", "Generate PIN", cmdParameters.toArray(new Loggeable[0])));
evt.addMessage(new SimpleMsg("command", "Generate PIN", cmdParameters.toArray(new Loggeable[cmdParameters.size()])));
EncryptedPIN result = null;
try {
result = generatePINImpl(accountNumber, pinLen, excludes);
Expand Down Expand Up @@ -381,7 +381,7 @@ public String calculatePVV(EncryptedPIN pinUnderLMK, SecureDESKey pvkA,
if(excludes != null && !excludes.isEmpty())
cmdParameters.add(new SimpleMsg("parameter", "Excluded PINs list", excludes));
LogEvent evt = new LogEvent(this, "s-m-operation");
evt.addMessage(new SimpleMsg("command", "Calculate PVV", cmdParameters.toArray(new Loggeable[0])));
evt.addMessage(new SimpleMsg("command", "Calculate PVV", cmdParameters.toArray(new Loggeable[cmdParameters.size()])));
String result = null;
try {
result = calculatePVVImpl(pinUnderLMK, pvkA, pvkB, pvkIdx, excludes);
Expand Down Expand Up @@ -414,7 +414,7 @@ public String calculatePVV(EncryptedPIN pinUnderKd1, SecureDESKey kd1,
if(excludes != null && !excludes.isEmpty())
cmdParameters.add(new SimpleMsg("parameter", "Excluded PINs list", excludes));
LogEvent evt = new LogEvent(this, "s-m-operation");
evt.addMessage(new SimpleMsg("command", "Calculate PVV", cmdParameters.toArray(new Loggeable[0])));
evt.addMessage(new SimpleMsg("command", "Calculate PVV", cmdParameters.toArray(new Loggeable[cmdParameters.size()])));
String result = null;
try {
result = calculatePVVImpl(pinUnderKd1, kd1, pvkA, pvkB, pvkIdx, excludes);
Expand Down Expand Up @@ -474,7 +474,7 @@ public String calculateIBMPINOffset(EncryptedPIN pinUnderLmk, SecureDESKey pvk,
if(excludes != null && !excludes.isEmpty())
cmdParameters.add(new SimpleMsg("parameter", "Excluded PINs list", excludes));
LogEvent evt = new LogEvent(this, "s-m-operation");
evt.addMessage(new SimpleMsg("command", "Calculate PIN offset", cmdParameters.toArray(new Loggeable[0])));
evt.addMessage(new SimpleMsg("command", "Calculate PIN offset", cmdParameters.toArray(new Loggeable[cmdParameters.size()])));
String result = null;
try {
result = calculateIBMPINOffsetImpl(pinUnderLmk, pvk,
Expand Down Expand Up @@ -510,7 +510,7 @@ public String calculateIBMPINOffset(EncryptedPIN pinUnderKd1, SecureDESKey kd1,
if(excludes != null && !excludes.isEmpty())
cmdParameters.add(new SimpleMsg("parameter", "Excluded PINs list", excludes));
LogEvent evt = new LogEvent(this, "s-m-operation");
evt.addMessage(new SimpleMsg("command", "Calculate PIN offset", cmdParameters.toArray(new Loggeable[0])));
evt.addMessage(new SimpleMsg("command", "Calculate PIN offset", cmdParameters.toArray(new Loggeable[cmdParameters.size()])));
String result = null;
try {
result = calculateIBMPINOffsetImpl(pinUnderKd1, kd1, pvk,
Expand Down

0 comments on commit 792ab2f

Please sign in to comment.