[yum-commits] Branch 'yum-3_2_X' - 2 commits - yum/misc.py
Ville Skyttä
scop at osuosl.org
Thu Oct 29 07:33:56 UTC 2009
yum/misc.py | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
New commits:
commit 5823850e28f9b716976dce1b6d7f7ef2221cfca9
Author: Ville Skyttä <ville.skytta at iki.fi>
Date: Wed Oct 28 23:15:47 2009 +0200
Simplify re_full_search_needed "primary" regex.
diff --git a/yum/misc.py b/yum/misc.py
index a689b16..3e86d08 100644
--- a/yum/misc.py
+++ b/yum/misc.py
@@ -115,8 +115,8 @@ def re_full_search_needed(s):
""" Tests if a string needs a full nevra match, instead of just name. """
global _re_compiled_full_match
if _re_compiled_full_match is None:
- # A glob, or a "." or "-" separator
- one = re.compile('.*([-.*?]|\[.+\]).*.$').match
+ # A glob, or a "." or "-" separator, followed by something (the ".")
+ one = re.compile('.*([-.*?]|\[.+\]).').match
# Any epoch, for envra
two = re.compile('[0-9]+:').match
_re_compiled_full_match = (one, two)
commit 82db896e0730f445b1f5efc21f0ec8114b511a21
Author: Ville Skyttä <ville.skytta at iki.fi>
Date: Sat Oct 17 17:27:32 2009 +0300
Cache regex match/search function instead of the regex for a small speedup.
diff --git a/yum/misc.py b/yum/misc.py
index 26bbaba..a689b16 100644
--- a/yum/misc.py
+++ b/yum/misc.py
@@ -78,8 +78,8 @@ def re_glob(s):
""" Tests if a string is a shell wildcard. """
global _re_compiled_glob_match
if _re_compiled_glob_match is None:
- _re_compiled_glob_match = re.compile('.*([*?]|\[.+\])')
- return _re_compiled_glob_match.match(s)
+ _re_compiled_glob_match = re.compile('[*?]|\[.+\]').search
+ return _re_compiled_glob_match(s)
_re_compiled_filename_match = None
def re_filename(s):
@@ -87,8 +87,8 @@ def re_filename(s):
classes wrong (are they supported), and ranges in character classes. """
global _re_compiled_filename_match
if _re_compiled_filename_match is None:
- _re_compiled_filename_match = re.compile('[/*?]|\[[^]]*/[^]]*\]')
- return _re_compiled_filename_match.match(s)
+ _re_compiled_filename_match = re.compile('[/*?]|\[[^]]*/[^]]*\]').match
+ return _re_compiled_filename_match(s)
def re_primary_filename(filename):
""" Tests if a filename string, can be matched against just primary.
@@ -115,11 +115,13 @@ def re_full_search_needed(s):
""" Tests if a string needs a full nevra match, instead of just name. """
global _re_compiled_full_match
if _re_compiled_full_match is None:
- one = re.compile('.*([-.*?]|\[.+\]).*.$') # Any wildcard, "." or "-"
- two = re.compile('^[0-9]+:') # Any epoch, for envra
+ # A glob, or a "." or "-" separator
+ one = re.compile('.*([-.*?]|\[.+\]).*.$').match
+ # Any epoch, for envra
+ two = re.compile('[0-9]+:').match
_re_compiled_full_match = (one, two)
for rec in _re_compiled_full_match:
- if rec.match(s):
+ if rec(s):
return True
return False
More information about the Yum-commits
mailing list