Skip to content

Commit a4bf602

Browse files
authored
Merge pull request #96 from fluent-plugins-nursery/improve-perf
Improve performance
2 parents 3e7b94a + 7b92d7d commit a4bf602

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

lib/fluent/plugin/filter_concat.rb

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -113,12 +113,12 @@ def shutdown
113113
end
114114

115115
def filter_stream(tag, es)
116+
if /\Afluent\.(?:trace|debug|info|warn|error|fatal)\z/ =~ tag
117+
return es
118+
end
119+
116120
new_es = Fluent::MultiEventStream.new
117121
es.each do |time, record|
118-
if /\Afluent\.(?:trace|debug|info|warn|error|fatal)\z/ =~ tag
119-
new_es.add(time, record)
120-
next
121-
end
122122
unless record.key?(@key)
123123
new_es.add(time, record)
124124
next
@@ -130,7 +130,7 @@ def filter_stream(tag, es)
130130
end
131131
end
132132
if @mode == :partial_metadata
133-
unless record.key?("partial_message")
133+
unless record.key?("partial_message".freeze)
134134
new_es.add(time, record)
135135
next
136136
end
@@ -146,10 +146,10 @@ def filter_stream(tag, es)
146146
merged_record.delete(@partial_key) unless @keep_partial_key
147147
when :partial_metadata
148148
unless @keep_partial_metadata
149-
merged_record.delete("partial_message")
150-
merged_record.delete("partial_id")
151-
merged_record.delete("partial_ordinal")
152-
merged_record.delete("partial_last")
149+
merged_record.delete("partial_message".freeze)
150+
merged_record.delete("partial_id".freeze)
151+
merged_record.delete("partial_ordinal".freeze)
152+
merged_record.delete("partial_last".freeze)
153153
end
154154
end
155155
new_es.add(time, merged_record)
@@ -288,16 +288,16 @@ def process_regexp(stream_identity, tag, time, record)
288288
end
289289

290290
def firstline?(text)
291-
@multiline_start_regexp && !!@multiline_start_regexp.match(text)
291+
@multiline_start_regexp && @multiline_start_regexp.match?(text)
292292
end
293293

294294
def lastline?(text)
295-
@multiline_end_regexp && !!@multiline_end_regexp.match(text)
295+
@multiline_end_regexp && @multiline_end_regexp.match?(text)
296296
end
297297

298298
def continuous_line?(text)
299299
if @continuous_line_regexp
300-
!!@continuous_line_regexp.match(text)
300+
@continuous_line_regexp.match?(text)
301301
else
302302
true
303303
end

0 commit comments

Comments
 (0)