Merge lp:~stolowski/unity-scope-manpages/compile-regex-once into lp:unity-scope-manpages

Proposed by Paweł Stołowski on 2013-05-13
Status: Merged
Approved by: David Callé on 2013-05-13
Approved revision: 31
Merged at revision: 31
Proposed branch: lp:~stolowski/unity-scope-manpages/compile-regex-once
Merge into: lp:unity-scope-manpages
Diff against target: 20 lines (+1/-2)
1 file modified
src/unity_manpages_daemon.py (+1/-2)
To merge this branch: bzr merge lp:~stolowski/unity-scope-manpages/compile-regex-once
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve on 2013-05-13
David Callé 2013-05-13 Approve on 2013-05-13
Review via email: mp+163566@code.launchpad.net

Commit message

Compile regex for apropos output parsing only once

Description of the change

Regex compilation is expensive, so compile regex for apropos results parsing only once.

To post a comment you must log in.
31. By Paweł Stołowski on 2013-05-13

Regex compilation is expensive, so compile regex for apropos results parsing only once.

David Callé (davidc3) wrote :

+1

review: Approve
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/unity_manpages_daemon.py' (properties changed: -x to +x)
2--- src/unity_manpages_daemon.py 2013-03-29 23:02:38 +0000
3+++ src/unity_manpages_daemon.py 2013-05-13 16:19:23 +0000
4@@ -51,7 +51,7 @@
5
6 EXTRA_METADATA = []
7
8-
9+regex_apropos = re.compile('^(.+?)\s+\((\d+)\)\s+-\s(.+?)$')
10 def search(search, filters):
11 '''
12 Use apropos to search for manpages matching the search string
13@@ -65,7 +65,6 @@
14 out = apropos.communicate()[0]
15 out = out.decode('utf8')
16 for line in out.split("\n"):
17- regex_apropos = re.compile('^(.+?)\s+\((\d+)\)\s+-\s(.+?)$')
18 m = regex_apropos.match(line)
19 if m:
20 result.append((m.group(1), m.group(2), m.group(3)))

Subscribers

People subscribed via source and target branches