mirror of
https://github.com/miniflux/v2.git
synced 2025-07-22 17:18:37 +00:00
perf(reader): optimize RemoveTrackingParameters
A bit more than 10% of processor.ProcessFeedEntries' CPU time is spent in urlcleaner.RemoveTrackingParameters, specifically calling url.Parse, so let's extract this operation outside of it, and do it once before calling urlcleaner.RemoveTrackingParameters multiple times. Co-authored-by: Frédéric Guillot <f@miniflux.net>
This commit is contained in:
parent
0caadf82f2
commit
7c857bdc72
4 changed files with 23 additions and 28 deletions
|
@ -227,6 +227,8 @@ func sanitizeAttributes(baseURL, tagName string, attributes []html.Attribute, sa
|
|||
isImageLargerThanLayout = imgWidth > 750
|
||||
}
|
||||
|
||||
parsedBaseUrl, _ := url.Parse(baseURL)
|
||||
|
||||
for _, attribute := range attributes {
|
||||
value := attribute.Val
|
||||
|
||||
|
@ -283,7 +285,8 @@ func sanitizeAttributes(baseURL, tagName string, attributes []html.Attribute, sa
|
|||
}
|
||||
|
||||
// TODO use feedURL instead of baseURL twice.
|
||||
if cleanedURL, err := urlcleaner.RemoveTrackingParameters(baseURL, baseURL, value); err == nil {
|
||||
parsedValueUrl, _ := url.Parse(value)
|
||||
if cleanedURL, err := urlcleaner.RemoveTrackingParameters(parsedBaseUrl, parsedBaseUrl, parsedValueUrl); err == nil {
|
||||
value = cleanedURL
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue