Permalink
Browse files

reuse result of operation on a variable, so that variable doesn't need

to be GetLocal'd twice
  • Loading branch information...
1 parent 9cc8e74 commit b6939a46237defe75e1d83632d222eb4ab0757a7 @mherkender committed Mar 18, 2012
Showing with 141 additions and 135 deletions.
  1. +13 −7 sha1-generator.py
  2. +128 −128 sha1.as
View
@@ -13,11 +13,17 @@
k = 0xCA62C1D6
if j < 16:
print "var w%s:uint = byteInput.readUnsignedInt();" % j
+ print "tmp = ((a << 5) | (a >>> 27)) + (%s) + e + 0x%08X + w%s; " \
+ "e = d; " \
+ "d = c; " \
+ "c = (b << 30) | (b >>> 2); " \
+ "b = a; " \
+ "a = tmp;" % (f, k, j % 16)
else:
- print "w%s ^= w%s ^ w%s ^ w%s; w%s = (w%s << 1) | (w%s >>> 31);" % (j % 16, (j - 3) % 16, (j - 8) % 16, (j - 14) % 16, j % 16, j % 16, j % 16)
- print "tmp = ((a << 5) | (a >>> 27)) + (%s) + e + 0x%08X + w%s; " \
- "e = d; " \
- "d = c; " \
- "c = (b << 30) | (b >>> 2); " \
- "b = a; " \
- "a = tmp;" % (f, k, j % 16)
+ print "w%s ^= w%s ^ w%s ^ w%s;" % (j % 16, (j - 3) % 16, (j - 8) % 16, (j - 14) % 16)
+ print "tmp = ((a << 5) | (a >>> 27)) + (%s) + e + 0x%08X + (w%s = (w%s << 1) | (w%s >>> 31)); " \
+ "e = d; " \
+ "d = c; " \
+ "c = (b << 30) | (b >>> 2); " \
+ "b = a; " \
+ "a = tmp;" % (f, k, j % 16, j % 16, j % 16)
Oops, something went wrong.

0 comments on commit b6939a4

Please sign in to comment.