Fix speed issue

Erik Johnson pointed out the speed issue with compelling numbers:

>>> import timeit
>>> t1 = timeit.Timer('clock == "localtime"', 'clock = "localtime"')
>>> t2 = timeit.Timer('clock.__eq__("localtime")', 'clock = "localtime"')
>>> t1.repeat()
[0.061421871185302734, 0.0285952091217041, 0.026736021041870117]
>>> t2.repeat()
[0.1310901641845703, 0.09536910057067871, 0.09479284286499023]

I'll absolutely fix it by using the simple '==' operator.

Thank you!
This commit is contained in:
Jεan Sacren 2016-06-02 10:49:46 -06:00 committed by rallytime
parent a41146730a
commit a6a446121a

View file

@ -404,7 +404,7 @@ def set_hwclock(clock):
raise SaltInvocationError(
'Only \'UTC\' and \'localtime\' are allowed'
)
if clock.__eq__('localtime'):
if clock == 'localtime':
clock = 'local'
__salt__['file.sed'](
'/etc/conf.d/hwclock', '^clock=.*', 'clock="{0}"'.format(clock))