Micro-optimization: replace s.find(x)!=-1 with x in s

timeit shows a speedup of ~3x on Python 2.7.5 x86_64.
It also makes the code a bit shorter.
This commit is contained in:
Cristian Ciupitu 2014-03-27 19:56:33 +02:00
commit 1eaf85b89f
4 changed files with 5 additions and 5 deletions

View file

@ -98,7 +98,7 @@ def not_in_host_file(self, host):
host_fh.close()
for line in data.split("\n"):
if line is None or line.find(" ") == -1:
if line is None or " " not in line:
continue
tokens = line.split()
if tokens[0].find(HASHED_KEY_MAGIC) == 0: