Skip to content

Commit b9bf2f5

Browse files
corona10mvdan
authored andcommitted
html/template: micro optimization for isJSType
There is an unnecessary lower operation in isJSType. Simple logic fix can improve tiny performance. name old time/op new time/op delta isJSType-8 152ns ± 0% 58ns ± 7% -61.82% (p=0.001 n=6+8) name old alloc/op new alloc/op delta isJSType-8 32.0B ± 0% 0.0B -100.00% (p=0.000 n=8+8) name old allocs/op new allocs/op delta isJSType-8 1.00 ± 0% 0.00 -100.00% (p=0.000 n=8+8) Change-Id: I281aadf1677d4377920c9649af206381189a27e6 Reviewed-on: https://go-review.googlesource.com/c/go/+/177118 Run-TryBot: Daniel Martí <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Daniel Martí <[email protected]>
1 parent 72e71b9 commit b9bf2f5

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/html/template/js.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,11 +383,11 @@ func isJSType(mimeType string) bool {
383383
// https://tools.ietf.org/html/rfc7231#section-3.1.1
384384
// https://tools.ietf.org/html/rfc4329#section-3
385385
// https://www.ietf.org/rfc/rfc4627.txt
386-
mimeType = strings.ToLower(mimeType)
387386
// discard parameters
388387
if i := strings.Index(mimeType, ";"); i >= 0 {
389388
mimeType = mimeType[:i]
390389
}
390+
mimeType = strings.ToLower(mimeType)
391391
mimeType = strings.TrimSpace(mimeType)
392392
switch mimeType {
393393
case

0 commit comments

Comments
 (0)