Commit b11894c1 by Őry Máté

vm: use set() for 'in' in a loop

https://wiki.python.org/moin/TimeComplexity
parent 983d1187
...@@ -37,7 +37,7 @@ VNC_PORT_RANGE = (2000, 65536) # inclusive start, exclusive end ...@@ -37,7 +37,7 @@ VNC_PORT_RANGE = (2000, 65536) # inclusive start, exclusive end
def find_unused_vnc_port(): def find_unused_vnc_port():
used = Instance.objects.values_list('vnc_port', flat=True) used = set(Instance.objects.values_list('vnc_port', flat=True))
for p in xrange(*VNC_PORT_RANGE): for p in xrange(*VNC_PORT_RANGE):
if p not in used: if p not in used:
return p return p
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment