Skip to content

Commit

Permalink
Use String#squeeze instead of String#gsub
Browse files Browse the repository at this point in the history
Because String#squeeze is about 7x faster than String#gsub.
See also https://gist.github.com/okkez/6e199011505c6db7e2e1003cc94f8cbc

Signed-off-by: Kenji Okimoto <[email protected]>
  • Loading branch information
okkez committed Dec 20, 2018
1 parent 94382d6 commit 9b72afb
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/fluent/plugin/parser_syslog.rb
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def parse_plain(text, &block)
when "pri"
record['pri'] = value.to_i
when "time"
time = @mutex.synchronize { @time_parser.parse(value.gsub(/ +/, ' ')) }
time = @mutex.synchronize { @time_parser.parse(value.squeeze(' ')) }
record[name] = value if @keep_time_key
else
record[name] = value
Expand Down

0 comments on commit 9b72afb

Please sign in to comment.