go/internal/span
Alan Donovan cbb8e8e923 internal/span: optimise URI.Filename to avoid allocation
This change adds a fast-path check for the common case:
"file:", lowercase, followed by a simple POSIX absolute
file name without special characters.

This function used to account for 1% of CPU on the DidChange
benchmark (and I'm sure I've seen higher fractions on other
tests--but perhaps that was before the clone optimizations?).

It was tested by adding an assertion that it agrees with the
slow path and running all our tests.

Change-Id: I15492b8a317715468870b00041bf8f6b0bb53bb2
Reviewed-on: https://go-review.googlesource.com/c/tools/+/411900
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
Run-TryBot: Alan Donovan <adonovan@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
2022-06-22 02:37:34 +00:00
..
parse.go internal/lsp/cache: parse filenames from go list errors correctly 2021-03-02 01:39:30 +00:00
span.go internal/span: eliminate TokenConverter 2022-06-01 19:19:15 +00:00
span_test.go internal/span: eliminate TokenConverter 2022-06-01 19:19:15 +00:00
token.go internal/span: eliminate TokenConverter 2022-06-01 19:19:15 +00:00
token_test.go internal/span: eliminate TokenConverter 2022-06-01 19:19:15 +00:00
uri.go internal/span: optimise URI.Filename to avoid allocation 2022-06-22 02:37:34 +00:00
uri_test.go all: go fmt ./... 2021-02-20 03:28:52 +00:00
uri_windows_test.go all: go fmt ./... 2021-02-20 03:28:52 +00:00
utf16.go internal/lsp/mod: fix broken assumptions about file base 2022-06-01 22:04:06 +00:00
utf16_test.go internal/span: remove check for nil content 2020-09-02 00:13:12 +00:00