Skip to content

Commit

Permalink
2.0.2 - Performance
Browse files Browse the repository at this point in the history
  • Loading branch information
icidasset committed Apr 25, 2019
1 parent 6eaa78c commit 6b48604
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
# Changelog


#### 2.0.2

Another performance bump.


#### 2.0.1

Major performance improvements.
Expand Down
2 changes: 1 addition & 1 deletion elm.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"name": "icidasset/elm-sha",
"summary": "SHA cryptographic hash functions.",
"license": "MIT",
"version": "2.0.1",
"version": "2.0.2",
"exposed-modules": [
"SHA"
],
Expand Down
12 changes: 3 additions & 9 deletions src/SHA/Internal/Common.elm
Original file line number Diff line number Diff line change
Expand Up @@ -48,24 +48,18 @@ combine : Int -> Bits -> Bits -> Bits
combine sizeInBits x y =
let
sum =
Binary.dropLeadingZeros (Binary.add x y)
Binary.add x y

width =
Binary.width sum
in
if width > sizeInBits then
let
excess =
width - sizeInBits
in
-- Is the sum larger than the modulo constant (ie. 2 ^ sizeInBits)?
sum
|> Binary.toBooleans
|> List.drop excess
|> List.drop (width - sizeInBits)
|> Binary.fromBooleans
|> Binary.dropLeadingZeros
|> Binary.ensureSize sizeInBits

else
-- If not, carry on.
Binary.ensureSize sizeInBits sum
sum

0 comments on commit 6b48604

Please sign in to comment.