Permalink
Browse files

reused static byte array

  • Loading branch information...
mherkender committed Mar 18, 2012
1 parent 6aeae94 commit 506c00742f997268f5f076629743d7716b3f062e
Showing with 8 additions and 2 deletions.
  1. +8 −2 sha1.as
View
10 sha1.as
@@ -2,8 +2,7 @@ package {
import flash.utils.ByteArray;
public function sha1(input:String):String {
var byteInput:ByteArray = new ByteArray();
byteInput.endian = "bigEndian";
var byteInput:ByteArray = staticByteArray;
byteInput.writeUTFBytes(input);
var originalLength:uint = byteInput.length;
@@ -125,6 +124,8 @@ package {
h3 += d;
h4 += e;
}
byteInput.length = 0;// cleanup
var result:String = uint(h4).toString(16);
var zeros:Array = staticZeros;
@@ -148,4 +149,9 @@ package {
}
}
import flash.utils.ByteArray;
const staticByteArray:ByteArray = new ByteArray();
staticByteArray.endian = "bigEndian";
const staticZeros:Array = ["", "0", "00", "000", "0000", "00000", "000000", "0000000"];

0 comments on commit 506c007

Please sign in to comment.