You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by se...@apache.org on 2012/09/09 15:10:38 UTC
svn commit: r1382490 -
/commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/binary/BaseNCodec.java
Author: sebb
Date: Sun Sep 9 13:10:38 2012
New Revision: 1382490
URL: http://svn.apache.org/viewvc?rev=1382490&view=rev
Log:
Don't create Context if it is not needed.
Modified:
commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/binary/BaseNCodec.java
Modified: commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/binary/BaseNCodec.java
URL: http://svn.apache.org/viewvc/commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/binary/BaseNCodec.java?rev=1382490&r1=1382489&r2=1382490&view=diff
==============================================================================
--- commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/binary/BaseNCodec.java (original)
+++ commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/binary/BaseNCodec.java Sun Sep 9 13:10:38 2012
@@ -377,10 +377,10 @@ public abstract class BaseNCodec impleme
*/
@Override
public byte[] decode(byte[] pArray) {
- Context context = new Context();
if (pArray == null || pArray.length == 0) {
return pArray;
}
+ Context context = new Context();
decode(pArray, 0, pArray.length, context);
decode(pArray, 0, EOF, context); // Notify decoder of EOF.
byte[] result = new byte[context.pos];
@@ -397,10 +397,10 @@ public abstract class BaseNCodec impleme
*/
@Override
public byte[] encode(byte[] pArray) {
- Context context = new Context();
if (pArray == null || pArray.length == 0) {
return pArray;
}
+ Context context = new Context();
encode(pArray, 0, pArray.length, context);
encode(pArray, 0, EOF, context); // Notify encoder of EOF.
byte[] buf = new byte[context.pos - context.readPos];