From efe15b97c316706a029d912066104923699068d2 Mon Sep 17 00:00:00 2001
From: Martin Mares <mj@ucw.cz>
Date: Wed, 24 Apr 2019 22:58:25 +0200
Subject: [PATCH] Cuckoo hashing: Improved readability

---
 09-cuckoo_hash/python/cuckoo_hash.py | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/09-cuckoo_hash/python/cuckoo_hash.py b/09-cuckoo_hash/python/cuckoo_hash.py
index 73f223e..a224d64 100644
--- a/09-cuckoo_hash/python/cuckoo_hash.py
+++ b/09-cuckoo_hash/python/cuckoo_hash.py
@@ -46,8 +46,7 @@ class CuckooTable:
         b0 = self.hashes[0].hash(key)
         b1 = self.hashes[1].hash(key)
         # print("## Lookup key={} b0={} b1={}".format(key, b0, b1))
-        return (self.table[b0] is not None and self.table[b0] == key) or \
-               (self.table[b1] is not None and self.table[b1] == key)
+        return self.table[b0] == key or self.table[b1] == key
 
     def insert(self, key):
         """Insert a new key to the table. Assumes that the key is not present yet."""
-- 
GitLab