As it turns out calling .strip() thousands of times can be expensive.
I'll defer to security groups and iptables experts to try and find ways
to call the method less often, cache the results, or any other clever
trick.
Moving strip to the return statement speeds up the method by more than
x2.
Change-Id: I7522c6db50c76274bef93e0f0ea6a78d508b7fbe
Related-Bug: #
1455675
def _find_last_entry(self, filter_list, match_str):
# find a matching entry, starting from the bottom
for s in reversed(filter_list):
- s = s.strip()
if match_str in s:
- return s
+ return s.strip()
def _modify_rules(self, current_lines, table, table_name):
# Chains are stored as sets to avoid duplicates.