mirror of
https://github.com/miniflux/v2.git
synced 2025-06-27 16:36:00 +00:00
perf(media): minor regex simplification
The previous regex was using the [ABC..D]*[ABC] pattern, resulting in a lot of backtracking. The new regex is stopping the matching at the first space or end of text (and removes the trailing `.` should one be present). The backtracking was taking around 50% of the CPU time spent in atom.Parse
This commit is contained in:
parent
da4ab4263c
commit
8660f5e3c7
1 changed files with 1 additions and 1 deletions
|
@ -9,7 +9,7 @@ import (
|
|||
"strings"
|
||||
)
|
||||
|
||||
var textLinkRegex = regexp.MustCompile(`(?mi)(\bhttps?:\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])`)
|
||||
var textLinkRegex = regexp.MustCompile(`(?mi)(\bhttps?://[^\s]+)[.]?(?:\s|$)`)
|
||||
|
||||
// Specs: https://www.rssboard.org/media-rss
|
||||
type MediaItemElement struct {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue