Skip to content

Commit 1515930

Browse files
keramsbaronfel
authored andcommitted
Remove string allocations (#9718)
1 parent b606af1 commit 1515930

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

src/fsharp/service/QuickParse.fs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ module QuickParse =
5252
FSharp.Compiler.Parser.tagOfToken (FSharp.Compiler.Parser.token.IDENT tokenText)
5353
else tokenTag
5454

55-
let rec isValidStrippedName (name:string) idx =
55+
let rec isValidStrippedName (name: ReadOnlySpan<char>) idx =
5656
if idx = name.Length then false
5757
elif IsIdentifierPartCharacter name.[idx] then true
5858
else isValidStrippedName name (idx + 1)
@@ -65,8 +65,8 @@ module QuickParse =
6565

6666
// Strip the surrounding bars (e.g. from "|xyz|_|") to get "xyz"
6767
match name.StartsWithOrdinal("|"), name.EndsWithOrdinal("|_|"), name.EndsWithOrdinal("|") with
68-
| true, true, _ when name.Length > 4 -> isValidStrippedName (name.Substring(1, name.Length - 4)) 0
69-
| true, _, true when name.Length > 2 -> isValidStrippedName (name.Substring(1, name.Length - 2)) 0
68+
| true, true, _ when name.Length > 4 -> isValidStrippedName (name.AsSpan(1, name.Length - 4)) 0
69+
| true, _, true when name.Length > 2 -> isValidStrippedName (name.AsSpan(1, name.Length - 2)) 0
7070
| _ -> false
7171

7272
let GetCompleteIdentifierIslandImpl (lineStr: string) (index: int) : (string * int * bool) option =

0 commit comments

Comments
 (0)