Skip to content

Commit

Permalink
perf: use URI::DEFAULT_PARSER instead of URI::Parser.new
Browse files Browse the repository at this point in the history
Signed-off-by: Šimon Lukašík <[email protected]>
  • Loading branch information
isimluk committed Sep 8, 2023
1 parent 79220ab commit a21dcab
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions lib/fluent/plugin/buffer/file_single_chunk.rb
Original file line number Diff line number Diff line change
Expand Up @@ -238,17 +238,16 @@ def file_rename(file, old_path, new_path, callback = nil)
callback.call(file) if callback
end

URI_PARSER = URI::Parser.new
ESCAPE_REGEXP = /[^-_.a-zA-Z0-9]/n

def encode_key(metadata)
k = @key ? metadata.variables[@key] : metadata.tag
k ||= ''
URI_PARSER.escape(k, ESCAPE_REGEXP)
URI::DEFAULT_PARSER.escape(k, ESCAPE_REGEXP)
end

def decode_key(key)
URI_PARSER.unescape(key)
URI::DEFAULT_PARSER.unescape(key)
end

def create_new_chunk(path, metadata, perm)
Expand Down

0 comments on commit a21dcab

Please sign in to comment.