mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Performance improvement using in-operator for hash lookups
Just a small cleanup for the existing occurrences. Using the in-operator for hash lookups is faster than using .has_key() http://stackoverflow.com/questions/1323410/has-key-or-in
This commit is contained in:
parent
85f6c26dff
commit
c843eeabc2
2 changed files with 3 additions and 3 deletions
|
@ -163,7 +163,7 @@ class Rhn(RegistrationBase):
|
|||
def get_option_default(self, key, default=''):
|
||||
# ignore pep8 W601 errors for this line
|
||||
# setting this to use 'in' does not work in the rhn library
|
||||
if self.has_key(key):
|
||||
if key in self:
|
||||
return self[key]
|
||||
else:
|
||||
return default
|
||||
|
|
|
@ -1715,7 +1715,7 @@ class DarwinUser(User):
|
|||
self.chown_homedir(int(self.uid), int(self.group), self.home)
|
||||
|
||||
for field in self.fields:
|
||||
if self.__dict__.has_key(field[0]) and self.__dict__[field[0]]:
|
||||
if field[0] in self.__dict__ and self.__dict__[field[0]]:
|
||||
|
||||
cmd = self._get_dscl()
|
||||
cmd += [ '-create', '/Users/%s' % self.name, field[1], self.__dict__[field[0]]]
|
||||
|
@ -1752,7 +1752,7 @@ class DarwinUser(User):
|
|||
self._make_group_numerical()
|
||||
|
||||
for field in self.fields:
|
||||
if self.__dict__.has_key(field[0]) and self.__dict__[field[0]]:
|
||||
if field[0] in self.__dict__ and self.__dict__[field[0]]:
|
||||
current = self._get_user_property(field[1])
|
||||
if current is None or current != self.__dict__[field[0]]:
|
||||
cmd = self._get_dscl()
|
||||
|
|
Loading…
Reference in a new issue