Skip to content

Commit 69c996a

Browse files
committed
refactor: use descriptive variable names in power_of_two.py
1 parent e2ebb76 commit 69c996a

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

data_structures/hashing/power_of_two.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,22 +19,22 @@
1919
VAL = TypeVar("VAL")
2020

2121

22-
def _next_power_of_two(n: int) -> int:
23-
if n < 1:
24-
raise ValueError("n must be >= 1")
25-
return 1 << (n - 1).bit_length()
22+
def _next_power_of_two(number: int) -> int:
23+
if number < 1:
24+
raise ValueError("number must be >= 1")
25+
return 1 << (number - 1).bit_length()
2626

2727

28-
def _mix_hash(h: int) -> int:
28+
def _mix_hash(hash_value: int) -> int:
2929
# Simple avalanching to make low bits more useful.
30-
h ^= h >> 16
31-
h *= 0x85EBCA6B
32-
h &= 0xFFFFFFFFFFFFFFFF
33-
h ^= h >> 13
34-
h *= 0xC2B2AE35
35-
h &= 0xFFFFFFFFFFFFFFFF
36-
h ^= h >> 16
37-
return h
30+
hash_value ^= hash_value >> 16
31+
hash_value *= 0x85EBCA6B
32+
hash_value &= 0xFFFFFFFFFFFFFFFF
33+
hash_value ^= hash_value >> 13
34+
hash_value *= 0xC2B2AE35
35+
hash_value &= 0xFFFFFFFFFFFFFFFF
36+
hash_value ^= hash_value >> 16
37+
return hash_value
3838

3939

4040
@dataclass(slots=True)

0 commit comments

Comments
 (0)