diff options
author | Guido Günther <agx@sigxcpu.org> | 2016-05-28 14:26:44 +0200 |
---|---|---|
committer | Guido Günther <agx@sigxcpu.org> | 2016-05-28 14:26:44 +0200 |
commit | f2d56788f18fcfc2bb4ba6dcf6f8da00a6321802 (patch) | |
tree | 025287b6460fbc11964a291c083f59b0bc50f128 | |
parent | 1f58d212630389ae87757d84cfe68b48e35553fa (diff) |
PatchSeries: compile patch level regex only once
-rw-r--r-- | gbp/patch_series.py | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/gbp/patch_series.py b/gbp/patch_series.py index 22025e0..4dcfe51 100644 --- a/gbp/patch_series.py +++ b/gbp/patch_series.py @@ -164,6 +164,7 @@ class PatchSeries(list): A series of L{Patch}es as read from a quilt series file). """ comment_re = re.compile('\s?#.*$') + level_re = re.compile('-p(?P<level>[0-9]+)') @classmethod def read_series_file(klass, seriesfile): @@ -242,8 +243,8 @@ class PatchSeries(list): """ return re.sub(klass.comment_re, '', line) - @staticmethod - def _split_strip(line): + @classmethod + def _split_strip(klass, line): """ Separate the -p<num> option from the patch name @@ -259,7 +260,7 @@ class PatchSeries(list): split = line.rsplit(None, 1) if len(split) > 1: - m = re.match('-p(?P<level>[0-9]+)', split[1]) + m = klass.level_re.match(split[1]) if m: patch = split[0] strip = int(m.group('level')) |