From: Angus Lees Date: Fri, 28 Nov 2014 01:18:49 +0000 (+1100) Subject: Remove unnecessary regex grouping X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=98cd8930744790ce4ac1f04408b3b593e856da75;p=openstack-build%2Fneutron-build.git Remove unnecessary regex grouping Several regexes in this class used had unnecessary (\s+) grouping. This change makes the regexes slightly cheaper by removing the need for the regex engine to remember the whitespace that was matched. Change-Id: I9381c213efe093dc472b0c7e9d7b303a0c7cb13b --- diff --git a/neutron/plugins/sriovnicagent/pci_lib.py b/neutron/plugins/sriovnicagent/pci_lib.py index f4108086c..313501275 100644 --- a/neutron/plugins/sriovnicagent/pci_lib.py +++ b/neutron/plugins/sriovnicagent/pci_lib.py @@ -28,10 +28,10 @@ class PciDeviceIPWrapper(ip_lib.IPWrapper): wrapper for getting/setting pci device details using ip link... """ - VF_PATTERN = "^vf(\s+)(?P\d+)(\s+)" - MAC_PATTERN = "MAC(\s+)(?P[a-fA-F0-9:]+)," - STATE_PATTERN = "(\s+)link-state(\s+)(?P\w+)" - ANY_PATTERN = "(.*)," + VF_PATTERN = r"^vf\s+(?P\d+)\s+" + MAC_PATTERN = r"MAC\s+(?P[a-fA-F0-9:]+)," + STATE_PATTERN = r"\s+link-state\s+(?P\w+)" + ANY_PATTERN = ".*," VF_LINE_FORMAT = VF_PATTERN + MAC_PATTERN + ANY_PATTERN + STATE_PATTERN VF_DETAILS_REG_EX = re.compile(VF_LINE_FORMAT)