From 6a07a508b877e09e9e99a8c7b2ff0e9b1e5e7428 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Van=20Canneyt?= Date: Thu, 24 Aug 2023 08:43:51 +0200 Subject: [PATCH] * Simplify GetEnumNameCount (by Lagprogramming). Fixes issue #40411 --- rtl/objpas/typinfo.pp | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/rtl/objpas/typinfo.pp b/rtl/objpas/typinfo.pp index 3ad3cb0b2d..7d13b89d1b 100644 --- a/rtl/objpas/typinfo.pp +++ b/rtl/objpas/typinfo.pp @@ -1212,29 +1212,21 @@ begin end; end; - function GetEnumNameCount(enum1: PTypeInfo): SizeInt; var PS: PShortString; - PT: PTypeData; - Count: SizeInt; begin - PT:=GetTypeData(enum1); if enum1^.Kind=tkBool then Result:=2 else begin - Count:=0; - Result:=0; - - PS:=@PT^.NameList; + PS:=@GetTypeData(enum1)^.NameList; + Result:=-1; While (PByte(PS)^<>0) do begin PS:=PShortString(pointer(PS)+PByte(PS)^+1); - Inc(Count); + Inc(Result); end; - { the last string is the unit name } - Result := Count - 1; end; end;