diff options
author | delthas <delthas@dille.cc> | 2022-04-15 21:06:08 +0200 |
---|---|---|
committer | delthas <delthas@dille.cc> | 2022-04-15 21:06:08 +0200 |
commit | c72f7fdb261b1e57874d59bbf99a43f0f56b6478 (patch) | |
tree | 2840dcd71df5f8914a3bc021cd9ee0f29420dbc6 /ui | |
parent | Batch events by time period rather than by fixed size (diff) |
Optimize URL regex
Following a quick local profiling & benchmark, matching links with
regexes is by far (>50x) the most time-consuming processing we do,
especially on start.
Switching to a URL regex with any scheme is faster by a factor of ~x8,
probably because there are many less "or" cases between a list of 100+
schemes, instead using a simple character class.
Diffstat (limited to 'ui')
-rw-r--r-- | ui/style.go | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/ui/style.go b/ui/style.go index d3869c1..47904c7 100644 --- a/ui/style.go +++ b/ui/style.go @@ -118,7 +118,7 @@ func (s StyledString) Truncate(w int, tail StyledString) StyledString { return sb.StyledString() } -var urlRegex = xurls.Relaxed() +var urlRegex, _ = xurls.StrictMatchingScheme(xurls.AnyScheme) func (s StyledString) ParseURLs() StyledString { if !strings.ContainsRune(s.string, '.') { |