Skip to content

Commit bc832a8

Browse files
auduchinokbaronfel
authored andcommitted
Optimize union case fields enumeration (#7840)
1 parent 487df5c commit bc832a8

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/fsharp/PatternMatchCompilation.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1031,7 +1031,7 @@ let CompilePatternBasic
10311031
(isNil origInputValTypars &&
10321032
not origInputVal.IsMemberOrModuleBinding &&
10331033
not ucref.Tycon.IsStructRecordOrUnionTycon &&
1034-
ucref.UnionCase.RecdFields.Length >= 1 &&
1034+
ucref.UnionCase.RecdFieldsArray.Length >= 1 &&
10351035
ucref.Tycon.UnionCasesArray.Length > 1) ->
10361036

10371037
let v, vExpr = mkCompGenLocal m "unionCase" (mkProvenUnionCaseTy ucref tinst)

src/fsharp/SignatureConformance.fs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -346,8 +346,8 @@ type Checker(g, amap, denv, remapInfo: SignatureRepackageInfo, checkingSig) =
346346
sigUnionCase.OtherRangeOpt <- Some (implUnionCase.Range, true)
347347
implUnionCase.OtherRangeOpt <- Some (sigUnionCase.Range, false)
348348
if implUnionCase.Id.idText <> sigUnionCase.Id.idText then err FSComp.SR.ModuleContainsConstructorButNamesDiffer
349-
elif implUnionCase.RecdFields.Length <> sigUnionCase.RecdFields.Length then err FSComp.SR.ModuleContainsConstructorButDataFieldsDiffer
350-
elif not (List.forall2 (checkField aenv) implUnionCase.RecdFields sigUnionCase.RecdFields) then err FSComp.SR.ModuleContainsConstructorButTypesOfFieldsDiffer
349+
elif implUnionCase.RecdFieldsArray.Length <> sigUnionCase.RecdFieldsArray.Length then err FSComp.SR.ModuleContainsConstructorButDataFieldsDiffer
350+
elif not (Array.forall2 (checkField aenv) implUnionCase.RecdFieldsArray sigUnionCase.RecdFieldsArray) then err FSComp.SR.ModuleContainsConstructorButTypesOfFieldsDiffer
351351
elif isLessAccessible implUnionCase.Accessibility sigUnionCase.Accessibility then err FSComp.SR.ModuleContainsConstructorButAccessibilityDiffers
352352
else checkAttribs aenv implUnionCase.Attribs sigUnionCase.Attribs (fun attribs -> implUnionCase.Attribs <- attribs)
353353

0 commit comments

Comments
 (0)