Improve performance of decryption loop #1
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi!
I'm the original author of the C 'ttm_unpack' program. I'm not a Python expert, but I've managed to clean up the main decryption loop a bit. (This is the bit with the nasty pointer arithmetic in the C version!)
Converting decryptState to hex is quite slow, so this does roughly does (though slightly less efficiently) and uses bit-shifts and bitwise and to extract the byte required.
In my tests, it performs roughly twice as fast as the original version (1m17s versus 2m55s), though neither are anywhere near as fast as the C version (which runs in around 2 seconds on my box).
Thanks for doing this port, it's quite amazing. I've put a webpage for the C version up at http://davidgow.net/hacks/ttm_unpack.html if you want a canonical place to check for any updates to it that I might do.
-- David