Skip to content
This repository has been archived by the owner on Dec 23, 2024. It is now read-only.

Commit

Permalink
Remove string allocations (dotnet#9718)
Browse files Browse the repository at this point in the history
  • Loading branch information
kerams authored and nosami committed Feb 22, 2021
1 parent 6b691f5 commit 4f20486
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion LanguageService/Symbols.fs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ type FSharpMemberOrFunctionOrValue with
member x.IsOperatorOrActivePattern =
let name = x.DisplayName
if name.StartsWith "( " && name.EndsWith " )" && name.Length > 4
then name.Substring (2, name.Length - 4) |> String.forall (fun c -> c <> ' ')
then name.IndexOf(' ', 2, name.Length - 4) = -1
else false


Expand Down
8 changes: 4 additions & 4 deletions LanguageService/Tokenizer.fs
Original file line number Diff line number Diff line change
Expand Up @@ -785,7 +785,7 @@ module internal Tokenizer =
let text = sourceText.GetSubText(span).ToString()
// backticked ident
if text.EndsWith "``" then
match text.[..text.Length - 3].LastIndexOf "``" with
match text.LastIndexOf("``", text.Length - 3, text.Length - 2) with
| -1 | 0 -> span
| index -> TextSpan(span.Start + index, text.Length - index)
else
Expand All @@ -798,9 +798,9 @@ module internal Tokenizer =

let isDoubleBacktickIdent (s: string) =
let doubledDelimiter = 2 * doubleBackTickDelimiter.Length
if s.StartsWith(doubleBackTickDelimiter) && s.EndsWith(doubleBackTickDelimiter) && s.Length > doubledDelimiter then
let inner = s.Substring(doubleBackTickDelimiter.Length, s.Length - doubledDelimiter)
not (inner.Contains(doubleBackTickDelimiter))
if s.Length > doubledDelimiter && s.StartsWith(doubleBackTickDelimiter, StringComparison.Ordinal) && s.EndsWith(doubleBackTickDelimiter, StringComparison.Ordinal) then
let inner = s.AsSpan(doubleBackTickDelimiter.Length, s.Length - doubledDelimiter)
not (inner.Contains(doubleBackTickDelimiter.AsSpan(), StringComparison.Ordinal))
else false

let isIdentifier (ident: string) =
Expand Down

0 comments on commit 4f20486

Please sign in to comment.