Skip to content

Commit a23a52c

Browse files
reduce allocations
1 parent ec7ae46 commit a23a52c

File tree

3 files changed

+17
-20
lines changed

3 files changed

+17
-20
lines changed

src/fsharp/MethodOverrides.fs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ module DispatchSlotChecking =
293293
match overrides |> List.filter (IsPartialMatch g amap m dispatchSlot) with
294294
| [] ->
295295
match overrides |> List.filter (fun overrideBy -> IsNameMatch dispatchSlot overrideBy &&
296-
IsImplMatch g dispatchSlot overrideBy) with
296+
IsImplMatch g dispatchSlot overrideBy) with
297297
| [] ->
298298
noimpl()
299299
| [ Override(_,_,_,(mtps,_),argTys,_,_,_) as overrideBy ] ->
@@ -307,12 +307,10 @@ module DispatchSlotChecking =
307307
errorR(Error(FSComp.SR.typrelOverloadNotFound(FormatMethInfoSig g amap m denv dispatchSlot, FormatMethInfoSig g amap m denv dispatchSlot),overrideBy.Range))
308308

309309
| [ overrideBy ] ->
310-
311-
match dispatchSlots |> List.filter (fun (RequiredSlot(dispatchSlot,_)) -> OverrideImplementsDispatchSlot g amap m dispatchSlot overrideBy) with
312-
| [] ->
310+
if dispatchSlots |> List.exists (fun (RequiredSlot(dispatchSlot,_)) -> OverrideImplementsDispatchSlot g amap m dispatchSlot overrideBy) then
313311
// Error will be reported below in CheckOverridesAreAllUsedOnce
314312
()
315-
| _ ->
313+
else
316314
noimpl()
317315

318316
| _ ->

src/fsharp/tast.fs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4398,19 +4398,18 @@ let fslibValRefEq fslibCcu vref1 vref2 =
43984398
/// This takes into account the possibility that they may have type forwarders
43994399
let primEntityRefEq compilingFslib fslibCcu (x : EntityRef) (y : EntityRef) =
44004400
x === y ||
4401-
match x.IsResolved,y.IsResolved with
4402-
| true, true when not compilingFslib -> x.ResolvedTarget === y.ResolvedTarget
4403-
| _ ->
4404-
match x.IsLocalRef,y.IsLocalRef with
4405-
| false, false when
4401+
4402+
if x.IsResolved && y.IsResolved && not compilingFslib then
4403+
x.ResolvedTarget === y.ResolvedTarget
4404+
elif not x.IsLocalRef && not y.IsLocalRef &&
44064405
(// Two tcrefs with identical paths are always equal
44074406
nonLocalRefEq x.nlr y.nlr ||
44084407
// The tcrefs may have forwarders. If they may possibly be equal then resolve them to get their canonical references
44094408
// and compare those using pointer equality.
4410-
(not (nonLocalRefDefinitelyNotEq x.nlr y.nlr) && x.Deref === y.Deref)) ->
4409+
(not (nonLocalRefDefinitelyNotEq x.nlr y.nlr) && x.Deref === y.Deref)) then
44114410
true
4412-
| _ ->
4413-
compilingFslib && fslibEntityRefEq fslibCcu x y
4411+
else
4412+
compilingFslib && fslibEntityRefEq fslibCcu x y
44144413

44154414
/// Primitive routine to compare two UnionCaseRef's for equality
44164415
let primUnionCaseRefEq compilingFslib fslibCcu (UCRef(tcr1,c1) as uc1) (UCRef(tcr2,c2) as uc2) =

src/utils/prim-lexing.fs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -184,9 +184,9 @@ namespace Internal.Utilities.Text.Lexing
184184
if lexBuffer.IsPastEndOfStream then failwith "End of file on lexing stream";
185185
lexBuffer.IsPastEndOfStream <- true;
186186
//printf "state %d --> %d on eof\n" state snew;
187-
scanUntilSentinel(lexBuffer,snew)
187+
scanUntilSentinel lexBuffer snew
188188
else
189-
scanUntilSentinel(lexBuffer, state)
189+
scanUntilSentinel lexBuffer state
190190

191191
let onAccept (lexBuffer:LexBuffer<char>,a) =
192192
lexBuffer.LexemeLength <- lexBuffer.BufferScanLength;
@@ -201,7 +201,7 @@ namespace Internal.Utilities.Text.Lexing
201201
let numUnicodeCategories = 30
202202
let numLowUnicodeChars = 128
203203
let numSpecificUnicodeChars = (trans.[0].Length - 1 - numLowUnicodeChars - numUnicodeCategories)/2
204-
let lookupUnicodeCharacters (state,inp) =
204+
let lookupUnicodeCharacters state inp =
205205
let inpAsInt = int inp
206206
// Is it a fast ASCII character?
207207
if inpAsInt < numLowUnicodeChars then
@@ -235,7 +235,7 @@ namespace Internal.Utilities.Text.Lexing
235235
loop 0
236236
let eofPos = numLowUnicodeChars + 2*numSpecificUnicodeChars + numUnicodeCategories
237237

238-
let rec scanUntilSentinel(lexBuffer,state) =
238+
let rec scanUntilSentinel lexBuffer state =
239239
// Return an endOfScan after consuming the input
240240
let a = int accept.[state]
241241
if a <> sentinel then
@@ -251,14 +251,14 @@ namespace Internal.Utilities.Text.Lexing
251251
let inp = lexBuffer.Buffer.[lexBuffer.BufferScanPos]
252252

253253
// Find the new state
254-
let snew = lookupUnicodeCharacters (state,inp)
254+
let snew = lookupUnicodeCharacters state inp
255255

256256
if snew = sentinel then
257257
lexBuffer.EndOfScan()
258258
else
259259
lexBuffer.BufferScanLength <- lexBuffer.BufferScanLength + 1;
260260
//printf "state %d --> %d on '%c' (%d)\n" s snew (char inp) inp;
261-
scanUntilSentinel(lexBuffer,snew)
261+
scanUntilSentinel lexBuffer snew
262262

263263
// Each row for the Unicode table has format
264264
// 128 entries for ASCII characters
@@ -268,6 +268,6 @@ namespace Internal.Utilities.Text.Lexing
268268

269269
member tables.Interpret(initialState,lexBuffer : LexBuffer<char>) =
270270
startInterpret(lexBuffer)
271-
scanUntilSentinel(lexBuffer, initialState)
271+
scanUntilSentinel lexBuffer initialState
272272

273273
static member Create(trans,accept) = new UnicodeTables(trans,accept)

0 commit comments

Comments
 (0)