summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rw-r--r--scripts/perfect_hash.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/scripts/perfect_hash.py b/scripts/perfect_hash.py
index 0d7df42..b94ed98 100644
--- a/scripts/perfect_hash.py
+++ b/scripts/perfect_hash.py
@@ -195,7 +195,9 @@ class StrSaltHash(object):
self.salt = ''
def __call__(self, key):
- while len(self.salt) < len(key): # add more salt as necessary
+ # XXX: xkbcommon modification: make the salt length a power of 2
+ # so that the % operation in the hash is fast.
+ while len(self.salt) < max(len(key), 32): # add more salt as necessary
self.salt += random.choice(self.chars)
return sum(ord(self.salt[i]) * ord(c)