From 9b72afb772c361502bdc9f2dec489f0702630d86 Mon Sep 17 00:00:00 2001 From: Kenji Okimoto Date: Thu, 20 Dec 2018 11:47:20 +0900 Subject: [PATCH] Use String#squeeze instead of String#gsub Because String#squeeze is about 7x faster than String#gsub. See also https://gist.github.com/okkez/6e199011505c6db7e2e1003cc94f8cbc Signed-off-by: Kenji Okimoto --- lib/fluent/plugin/parser_syslog.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/fluent/plugin/parser_syslog.rb b/lib/fluent/plugin/parser_syslog.rb index 778818a145..ea899169d6 100644 --- a/lib/fluent/plugin/parser_syslog.rb +++ b/lib/fluent/plugin/parser_syslog.rb @@ -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