]> git.proxmox.com Git - proxmox.git/commitdiff
http: websocket: avoid modulo for power of 2
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Fri, 4 Feb 2022 16:12:05 +0000 (17:12 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Fri, 4 Feb 2022 16:12:07 +0000 (17:12 +0100)
even for the small cases this can matter

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
proxmox-http/src/websocket/mod.rs

index 9c1f129ce963d20257ffc7b484cb843824290247..95a6f5131618b966f3a321d112e6bab7bcd02175 100644 (file)
@@ -114,7 +114,7 @@ fn mask_bytes(mask: Option<[u8; 4]>, data: &mut [u8]) {
 
     if data.len() < 32 {
         for i in 0..data.len() {
-            data[i] ^= mask[i % 4];
+            data[i] ^= mask[i & 3];
         }
         return;
     }