提交 e169caa4 编写于 作者: R Radostin Stoyanov 提交者: Daniel P. Berrangé

apibuild: Simplify uniq function

Use a set (unordered collections of unique elements) [1] to remove
repeated elements in a list.

1: https://docs.python.org/3/tutorial/datastructures.html#setsReviewed-by: NDaniel P. Berrangé <berrange@redhat.com>
Signed-off-by: NRadostin Stoyanov <rstoyanov1@gmail.com>
上级 94f417ba
...@@ -130,11 +130,7 @@ def escape(raw): ...@@ -130,11 +130,7 @@ def escape(raw):
return raw return raw
def uniq(items): def uniq(items):
d = {} return sorted(set(items))
for item in items:
d[item] = 1
k = sorted(d.keys())
return k
class identifier: class identifier:
def __init__(self, name, header=None, module=None, type=None, lineno=0, def __init__(self, name, header=None, module=None, type=None, lineno=0,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册