]> code.ossystems Code Review - openembedded-core.git/commitdiff
lib/oe/package_manager: Performance tweak in regex usage
authorRichard Purdie <richard.purdie@linuxfoundation.org>
Fri, 20 Feb 2015 17:41:41 +0000 (17:41 +0000)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Sat, 21 Feb 2015 22:04:25 +0000 (22:04 +0000)
Profiling a core-image-sato-sdk rootfs, we're spending over 40s
compiling the same regex over and over again, roughly around 5 million
times.

This is suboptimal, fix for a 40s improvement on a 18.5minute task execution
time.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
meta/lib/oe/package_manager.py

index f801333e54af1dbe64377509c0241fbf312d3995..69bef1dfbcceb514c95a3d576be52fede2dd88da 100644 (file)
@@ -679,10 +679,10 @@ class RpmPM(PackageManager):
     def _search_pkg_name_in_feeds(self, pkg, feed_archs):
         for arch in feed_archs:
             arch = arch.replace('-', '_')
+            regex_match = re.compile(r"^%s-[^-]*-[^-]*@%s$" % \
+                (re.escape(pkg), re.escape(arch)))
             for p in self.fullpkglist:
-                regex_match = r"^%s-[^-]*-[^-]*@%s$" % \
-                    (re.escape(pkg), re.escape(arch))
-                if re.match(regex_match, p) is not None:
+                if regex_match.match(p) is not None:
                     # First found is best match
                     # bb.note('%s -> %s' % (pkg, pkg + '@' + arch))
                     return pkg + '@' + arch