Created
October 3, 2011 17:32
-
-
Save kzk/1259689 to your computer and use it in GitHub Desktop.
match_cache.diff
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/lib/fluent/engine.rb b/lib/fluent/engine.rb | |
index 10e747c..6af8278 100644 | |
--- a/lib/fluent/engine.rb | |
+++ b/lib/fluent/engine.rb | |
@@ -22,6 +22,7 @@ class EngineClass | |
def initialize | |
@matches = [] | |
@sources = [] | |
+ @match_cache = {} | |
end | |
def init | |
@@ -106,8 +107,12 @@ class EngineClass | |
end | |
def emit_stream(tag, es) | |
- if match = @matches.find {|m| m.match(tag) } | |
+ if @match_cache.has_key?(tag) | |
+ match = @match_cache[tag] | |
match.emit(tag, es) | |
+ elsif match = @matches.find {|m| m.match(tag) } | |
+ match.emit(tag, es) | |
+ @match_cache[tag] = match | |
else | |
$log.on_trace { $log.trace "no pattern matched", :tag=>tag } | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment