Skip to content

Conversation

@bep
Copy link
Member

@bep bep commented May 25, 2022

Fix Plainify edge cases

This commit replaces the main part of helpers.StripHTML with Go's implementation in its html/template package.

It's a little slower, but correctness is more important:

BenchmarkStripHTMLOld-10          680316              1764 ns/op             728 B/op          4 allocs/op
BenchmarkStripHTMLNew-10          384520              3099 ns/op            2089 B/op         10 allocs/op

Fixes ##9199
Fixes #9909
Closes #9410

@bep bep force-pushed the fix/plainify-9909-9410 branch 2 times, most recently from 2d44562 to 0b15fc9 Compare May 25, 2022 12:44
This commit replaces the main part of `helpers.StripHTML` with Go's implementation in its html/template package.

It's a little slower, but correctness is more important:

```bash
BenchmarkStripHTMLOld-10    	  680316	      1764 ns/op	     728 B/op	       4 allocs/op
BenchmarkStripHTMLNew-10    	  384520	      3099 ns/op	    2089 B/op	      10 allocs/op
```

Fixes gohugoio#9199
Fixes gohugoio#9909
Closes gohugoio#9410
@bep bep force-pushed the fix/plainify-9909-9410 branch from 0b15fc9 to ff37b1c Compare May 25, 2022 15:14
@bep
Copy link
Member Author

bep commented May 25, 2022

I also compared this branch against the #9923

name          old time/op    new time/op    delta
StripHTML-10    3.19µs ± 5%   16.28µs ± 4%   +410.24%  (p=0.029 n=4+4)

name          old alloc/op   new alloc/op   delta
StripHTML-10    2.07kB ± 0%   13.44kB ± 0%   +548.34%  (p=0.029 n=4+4)

name          old allocs/op  new allocs/op  delta
StripHTML-10      10.0 ± 0%     163.0 ± 0%  +1530.00%  (p=0.029 n=4+4)
@bep bep merged commit 3854a6f into gohugoio:master May 25, 2022
@github-actions
Copy link

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 26, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

1 participant