Commit 98de954c authored by Perceval Guillou's avatar Perceval Guillou
Browse files

Merge branch '2790-hashobjsetting-code-improvement' into 'master'

Resolve "HashObjSetting code improvement"

Closes #2790

See merge request !3757
parents 5196fa02 b41f5182
Pipeline #47891 passed with stages
in 114 minutes and 2 seconds
...@@ -646,7 +646,6 @@ class BaseHashSetting(BaseSetting): ...@@ -646,7 +646,6 @@ class BaseHashSetting(BaseSetting):
def items(self): def items(self):
cnx = self.connection cnx = self.connection
next_id = 0 next_id = 0
seen_keys = set()
while True: while True:
next_id, pd = cnx.hscan(self.name, next_id) next_id, pd = cnx.hscan(self.name, next_id)
for k, v in pd.items(): for k, v in pd.items():
...@@ -654,9 +653,8 @@ class BaseHashSetting(BaseSetting): ...@@ -654,9 +653,8 @@ class BaseHashSetting(BaseSetting):
k = k.decode() k = k.decode()
if self._read_type_conversion: if self._read_type_conversion:
v = self._read_type_conversion(v) v = self._read_type_conversion(v)
seen_keys.add(k)
yield k, v yield k, v
if not next_id or next_id is "0": if not next_id or next_id == "0":
break break
def __getitem__(self, key): def __getitem__(self, key):
...@@ -959,20 +957,10 @@ class HashSetting(BaseHashSetting): ...@@ -959,20 +957,10 @@ class HashSetting(BaseHashSetting):
return all_dict return all_dict
def items(self): def items(self):
cnx = self.connection
next_id = 0
seen_keys = set() seen_keys = set()
while True: for k, v in super().items():
next_id, pd = cnx.hscan(self.name, next_id) seen_keys.add(k)
for k, v in pd.items(): yield k, v
# Add key conversion
k = k.decode()
if self._read_type_conversion:
v = self._read_type_conversion(v)
seen_keys.add(k)
yield k, v
if not next_id or next_id is "0":
break
for k, v in self._default_values.items(): for k, v in self._default_values.items():
if k in seen_keys: if k in seen_keys:
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment