1
0
Fork 0
mirror of https://github.com/miniflux/v2.git synced 2025-09-30 19:22:11 +00:00
miniflux-v2/internal/reader/sanitizer
Julien Voisin 5a97bf8b5e
refactor(sanitizer): simplify hasValidURIScheme and isBlockedResource functions
- use an array instead of a map for the schemes, as the overwhelming majority
  of them will be either http or https, which we can place in front of the
  array. This is faster than using a map.
- Simplify hasValidURIScheme by using strings.HasPrefix instead of doing
  strings.IndexByte
- Simplify isBlockedResource by using a simple for loop, instead of a weird
  slices.ContainsFunc+strings.Contains construct.

On my noisy system:

```
goos: linux
goarch: arm64
pkg: miniflux.app/v2/internal/reader/sanitizer
           │   old.txt   │            new.txt            │
           │   sec/op    │   sec/op     vs base          │
Sanitize-8   22.19m ± 4%   21.97m ± 4%  ~ (p=0.948 n=50)
```
2025-09-29 19:42:45 -07:00
..
testdata Speed the sanitizer up a bit, again 2024-03-05 19:31:50 -08:00
sanitizer.go refactor(sanitizer): simplify hasValidURIScheme and isBlockedResource functions 2025-09-29 19:42:45 -07:00
sanitizer_test.go refactor(config): rewrite config parser 2025-09-14 10:51:04 -07:00
srcset.go refactor: unexport symbols 2025-08-07 17:27:04 -07:00
srcset_test.go Move internal packages to an internal folder 2023-08-10 20:29:34 -07:00
strip_tags.go refactor(sanitizer): optimize internal/reader/sanitizer/strip_tags.go 2024-12-07 16:31:48 -08:00
strip_tags_test.go Move internal packages to an internal folder 2023-08-10 20:29:34 -07:00
truncate.go perf(sanitizer): remove two useless calls to strings.ReplaceAll 2025-02-18 19:42:39 -08:00
truncate_test.go feat(sanitizer): improve text truncation with better space handling 2025-02-06 21:21:49 -08:00