Optimise algorithm by reducing number of invocations
This commit is contained in:
parent
a47777ce23
commit
cac52effa8
@ -29,16 +29,16 @@ class Normalisename:
|
||||
def whitelist(self):
|
||||
return self._whitelist.union({self.separator})
|
||||
|
||||
def __call__(self, files):
|
||||
for path in files:
|
||||
if not self.check_normal(path):
|
||||
def __call__(self, paths):
|
||||
for path in paths:
|
||||
directory = dirname(path)
|
||||
filename = basename(path)
|
||||
normalpath = joinpath(directory, self.normalname(filename))
|
||||
if path != normalpath:
|
||||
self.operation(path, normalpath) # pylint: disable=not-callable
|
||||
|
||||
def check_normal(self, filename):
|
||||
filename = basename(filename)
|
||||
def check_normal(self, path):
|
||||
filename = basename(path)
|
||||
return filename == self.normalname(filename)
|
||||
|
||||
def normalname(self, filename):
|
||||
|
Loading…
Reference in New Issue
Block a user