From 98cd8930744790ce4ac1f04408b3b593e856da75 Mon Sep 17 00:00:00 2001 From: Angus Lees Date: Fri, 28 Nov 2014 12:18:49 +1100 Subject: [PATCH] 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 --- neutron/plugins/sriovnicagent/pci_lib.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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) -- 2.45.2