Skip to content

Commit 537a8fe

Browse files
authored
Do not check genericArgs.Length over and over again (#9244)
* Do not check genericArgs.Length over and over again * Use singleton match
1 parent d4b5b3a commit 537a8fe

1 file changed

Lines changed: 13 additions & 10 deletions

File tree

src/fsharp/import.fs

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -287,16 +287,19 @@ let rec ImportProvidedType (env: ImportMap) (m: range) (* (tinst: TypeInst) *) (
287287
tcref, []
288288

289289
/// Adjust for the known primitive numeric types that accept units of measure.
290-
let tcref =
291-
if tyconRefEq g tcref g.system_Double_tcref && genericArgs.Length = 1 then g.pfloat_tcr
292-
elif tyconRefEq g tcref g.system_Single_tcref && genericArgs.Length = 1 then g.pfloat32_tcr
293-
elif tyconRefEq g tcref g.system_Decimal_tcref && genericArgs.Length = 1 then g.pdecimal_tcr
294-
elif tyconRefEq g tcref g.system_Int16_tcref && genericArgs.Length = 1 then g.pint16_tcr
295-
elif tyconRefEq g tcref g.system_Int32_tcref && genericArgs.Length = 1 then g.pint_tcr
296-
elif tyconRefEq g tcref g.system_Int64_tcref && genericArgs.Length = 1 then g.pint64_tcr
297-
elif tyconRefEq g tcref g.system_SByte_tcref && genericArgs.Length = 1 then g.pint8_tcr
298-
else tcref
299-
290+
let tcref =
291+
match genericArgs with
292+
| [_] ->
293+
if tyconRefEq g tcref g.system_Double_tcref then g.pfloat_tcr
294+
elif tyconRefEq g tcref g.system_Single_tcref then g.pfloat32_tcr
295+
elif tyconRefEq g tcref g.system_Decimal_tcref then g.pdecimal_tcr
296+
elif tyconRefEq g tcref g.system_Int16_tcref then g.pint16_tcr
297+
elif tyconRefEq g tcref g.system_Int32_tcref then g.pint_tcr
298+
elif tyconRefEq g tcref g.system_Int64_tcref then g.pint64_tcr
299+
elif tyconRefEq g tcref g.system_SByte_tcref then g.pint8_tcr
300+
else tcref
301+
| _ -> tcref
302+
300303
let tps = tcref.Typars m
301304
if tps.Length <> genericArgs.Length then
302305
error(Error(FSComp.SR.impInvalidNumberOfGenericArguments(tcref.CompiledName, tps.Length, genericArgs.Length), m))

0 commit comments

Comments
 (0)