Skip to content

Commit

Permalink
Merge pull request #7 from athoune/master
Browse files Browse the repository at this point in the history
The cost of deepcopy is HUGE.
  • Loading branch information
garyelephant committed Nov 6, 2015
2 parents 03ed059 + 6035060 commit 5498e21
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions pygrok/pygrok.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ def grok_match(text, pattern, custom_patterns = {}, custom_patterns_dir = None):
predefined_patterns = _reload_patterns(DEFAULT_PATTERNS_DIRS)
loaded_pre_patterns = True

all_patterns = copy.deepcopy(predefined_patterns)

custom_pats = {}
if custom_patterns_dir is not None:
custom_pats = _reload_patterns([custom_patterns_dir])
Expand All @@ -39,7 +37,10 @@ def grok_match(text, pattern, custom_patterns = {}, custom_patterns_dir = None):
custom_pats[pat_name] = Pattern(pat_name, regex_str)

if len(custom_pats) > 0:
all_patterns = copy.deepcopy(predefined_patterns)
all_patterns.update(custom_pats)
else:
all_patterns = predefined_patterns

#attention: this may cause performance problems
py_regex_pattern = pattern
Expand Down

0 comments on commit 5498e21

Please sign in to comment.