Skip to content

Commit 7b1ddce

Browse files
HazATsl0thentr0py
authored andcommitted
perf: Optimize lowercase check in RequestInterface
1 parent 51dfec5 commit 7b1ddce

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

sentry-ruby/lib/sentry/interfaces/request.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,11 @@ def filter_and_format_headers(env, send_default_pii)
107107
end
108108
end
109109

110+
# Regex to detect lowercase chars — match? is allocation-free (no MatchData/String)
111+
LOWERCASE_PATTERN = /[a-z]/.freeze
112+
110113
def is_skippable_header?(key)
111-
key.upcase != key || # lower-case envs aren't real http headers
114+
key.match?(LOWERCASE_PATTERN) || # lower-case envs aren't real http headers
112115
key == "HTTP_COOKIE" || # Cookies don't go here, they go somewhere else
113116
!(key.start_with?("HTTP_") || CONTENT_HEADERS.include?(key))
114117
end

0 commit comments

Comments
 (0)