aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2025-01-13 13:23:05 +0100
committerLoïc Hoguin <[email protected]>2025-01-13 13:23:05 +0100
commit4594ab106e15ab9dd000233a620da31ff8da5326 (patch)
treee802b45ea6ef6b72a96505de04a852c24996f758
parentcdb769a9d33bf9c860f835c44ef445c52d21faae (diff)
downloadcowlib-4594ab106e15ab9dd000233a620da31ff8da5326.tar.gz
cowlib-4594ab106e15ab9dd000233a620da31ff8da5326.tar.bz2
cowlib-4594ab106e15ab9dd000233a620da31ff8da5326.zip
Avoid an extra multiplication before unmasking
This has no real impact on performance but simplies the code a little.
-rw-r--r--src/cow_ws.erl6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/cow_ws.erl b/src/cow_ws.erl
index 08790ca..47c9e89 100644
--- a/src/cow_ws.erl
+++ b/src/cow_ws.erl
@@ -520,9 +520,9 @@ unmask(Data, MaskKey, 0) ->
mask(Data, MaskKey, <<>>);
%% We unmask on the fly so we need to continue from the right mask byte.
unmask(Data, MaskKey, UnmaskedLen) ->
- Left = UnmaskedLen rem 4,
- Right = 4 - Left,
- MaskKey2 = (MaskKey bsl (Left * 8)) + (MaskKey bsr (Right * 8)),
+ Left = (UnmaskedLen rem 4) * 8,
+ Right = 32 - Left,
+ MaskKey2 = (MaskKey bsl Left) + (MaskKey bsr Right),
mask(Data, MaskKey2, <<>>).
mask(<< O1:32, O2:32, O3:32, O4:32, Rest/bits >>, MaskKey, Acc) ->