You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@santuario.apache.org by ra...@apache.org on 2006/08/05 19:42:51 UTC
svn commit: r429016 -
/xml/security/trunk/src/org/apache/xml/security/c14n/implementations/UtfHelpper.java
Author: raul
Date: Sat Aug 5 10:42:50 2006
New Revision: 429016
URL: http://svn.apache.org/viewvc?rev=429016&view=rev
Log:
Small optimization.
Modified:
xml/security/trunk/src/org/apache/xml/security/c14n/implementations/UtfHelpper.java
Modified: xml/security/trunk/src/org/apache/xml/security/c14n/implementations/UtfHelpper.java
URL: http://svn.apache.org/viewvc/xml/security/trunk/src/org/apache/xml/security/c14n/implementations/UtfHelpper.java?rev=429016&r1=429015&r2=429016&view=diff
==============================================================================
--- xml/security/trunk/src/org/apache/xml/security/c14n/implementations/UtfHelpper.java (original)
+++ xml/security/trunk/src/org/apache/xml/security/c14n/implementations/UtfHelpper.java Sat Aug 5 10:42:50 2006
@@ -89,7 +89,8 @@
public final static byte[] getStringInUtf8(final String str) {
final int length=str.length();
- byte []result=new byte[length*3];
+ boolean expanded=false;
+ byte []result=new byte[length];
int i=0;
int out=0;
char c;
@@ -99,6 +100,12 @@
result[out++]=(byte)c;
continue;
}
+ if (!expanded) {
+ byte newResult[]=new byte[3*length];
+ System.arraycopy(result, 0, newResult, 0, out);
+ result=newResult;
+ expanded=true;
+ }
char ch;
int bias;
byte write;
@@ -123,9 +130,12 @@
result[out++]=(byte)(0x80 | ((c) & 0x3F));
}
- byte newResult[]=new byte[out];
- System.arraycopy(result, 0, newResult, 0, out);
- return newResult;
+ if (expanded) {
+ byte newResult[]=new byte[out];
+ System.arraycopy(result, 0, newResult, 0, out);
+ result=newResult;
+ }
+ return result;
}