forked from josch/mmdebstrap
tarfilter: Compile prefix pattern only once
According to Debian bug #978742, mmtarfilter has a slow performance with many path exclusions. The execution can be speed up if the regular expression is only compiled once instead of every time in the hot loop. Signed-off-by: Benjamin Drung <benjamin.drung@cloud.ionos.com>
This commit is contained in:
parent
5fd1ca62d9
commit
043ab3bbf0
1 changed files with 2 additions and 1 deletions
|
@ -61,6 +61,7 @@ dpkg(1) for information on how these two options work in detail.
|
||||||
exit()
|
exit()
|
||||||
|
|
||||||
# same logic as in dpkg/src/filters.c/filter_should_skip()
|
# same logic as in dpkg/src/filters.c/filter_should_skip()
|
||||||
|
prefix_prog = re.compile(r"^([^*?[\\]*).*")
|
||||||
def filter_should_skip(member):
|
def filter_should_skip(member):
|
||||||
skip = False
|
skip = False
|
||||||
if not args.filter:
|
if not args.filter:
|
||||||
|
@ -75,7 +76,7 @@ dpkg(1) for information on how these two options work in detail.
|
||||||
for (t, r) in args.filter:
|
for (t, r) in args.filter:
|
||||||
if t != "path_include":
|
if t != "path_include":
|
||||||
continue
|
continue
|
||||||
prefix = re.sub(r"^([^*?[\\]*).*", r"\1", r.pattern)
|
prefix = prefix_prog.sub(r"\1", r.pattern)
|
||||||
prefix = prefix.rstrip("/")
|
prefix = prefix.rstrip("/")
|
||||||
if member.name[1:].startswith(prefix):
|
if member.name[1:].startswith(prefix):
|
||||||
if member.name == "./usr/share/doc/doc-debian":
|
if member.name == "./usr/share/doc/doc-debian":
|
||||||
|
|
Loading…
Reference in a new issue