Browse files

use a compiled regex for performance

  • Loading branch information...
1 parent e080a5f commit 4efdd3b359d71d7962fc7c65f74f3d1727610b92 @fogleman fogleman committed Dec 13, 2012
Showing with 2 additions and 1 deletion.
  1. +2 −1 git_gutter_handler.py
View
3 git_gutter_handler.py
@@ -65,9 +65,10 @@ def process_diff(self, diff_str):
inserted = []
modified = []
deleted = []
+ pattern = re.compile(r'(\d+),?(\d*)(.)(\d+),?(\d*)')
lines = diff_str.splitlines()
for line in lines:
- m = re.match('(\d+),?(\d*)(.)(\d+),?(\d*)', line)
+ m = pattern.match(line)
if not m:
continue
kind = m.group(3)

0 comments on commit 4efdd3b

Please sign in to comment.