SHA1CryptoServiceProvider.cs: Quick optimization to get better results with the JIT...
authorSebastien Pouliot <sebastien@ximian.com>
Mon, 28 Apr 2008 00:58:57 +0000 (00:58 -0000)
committerSebastien Pouliot <sebastien@ximian.com>
Mon, 28 Apr 2008 00:58:57 +0000 (00:58 -0000)
svn path=/trunk/mcs/; revision=102008

mcs/class/corlib/System.Security.Cryptography/ChangeLog
mcs/class/corlib/System.Security.Cryptography/SHA1CryptoServiceProvider.cs

index b32186568f39070383616470ea8fcf27040691ca..9b5cf11176edbb4095bf10b29dea9283bb58d620 100644 (file)
@@ -1,3 +1,8 @@
+2008-04-27  Sebastien Pouliot  <sebastien@ximian.com>
+
+       * SHA1CryptoServiceProvider.cs: Quick optimization to get better
+       results with the JIT (a bit over 25% on a 4GB file).
+
 2008-04-17  Sebastien Pouliot  <sebastien@ximian.com>
 
        * AsymmetricAlgorithm.cs: Add shared GetNamedParam helper method.
index 3c29055fc0ab5e0a6cea53c56027ee3ce043289e..fbddda77f47ee9d0ab2f5c404af451790f737b1f 100644 (file)
@@ -6,7 +6,7 @@
 //     Sebastien Pouliot (sebastien@ximian.com)
 //
 // Copyright 2001 by Matthew S. Ford.
-// Copyright (C) 2004, 2005 Novell, Inc (http://www.novell.com)
+// Copyright (C) 2004, 2005, 2008 Novell, Inc (http://www.novell.com)
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -121,7 +121,10 @@ namespace System.Security.Cryptography {
                        int i;
 
                        count += BLOCK_SIZE_BYTES;
-               
+
+                       // abc removal would not work on the fields
+                       uint[] _H = this._H;
+                       uint[] buff = this.buff;
                        for (i=0; i<16; i++) {
                                buff[i] = ((uint)(inputBuffer[inputOffset+4*i]) << 24)
                                        | ((uint)(inputBuffer[inputOffset+4*i+1]) << 16)
@@ -129,9 +132,10 @@ namespace System.Security.Cryptography {
                                        | ((uint)(inputBuffer[inputOffset+4*i+3]));
                        }
 
+                       uint zt;
                        for (i=16; i<80; i++) {
-                               buff[i] = ((buff[i-3] ^ buff[i-8] ^ buff[i-14] ^ buff[i-16]) << 1)
-                                       | ((buff[i-3] ^ buff[i-8] ^ buff[i-14] ^ buff[i-16]) >> 31);
+                               zt = buff[i-3] ^ buff[i-8] ^ buff[i-14] ^ buff[i-16];
+                               buff[i] = ((zt << 1) | (zt >> 31));
                        }
                
                        a = _H[0];