[Ada] Simplify code by reusing List_Length
authorPiotr Trojanek <trojanek@adacore.com>
Wed, 19 May 2021 10:06:55 +0000 (12:06 +0200)
committerPierre-Marie de Rodat <derodat@adacore.com>
Wed, 7 Jul 2021 16:23:14 +0000 (16:23 +0000)
gcc/ada/

* exp_disp.adb (CPP_Num_Prims): Reuse List_Length.

gcc/ada/exp_disp.adb

index a44af6a..e9d6e74 100644 (file)
@@ -588,19 +588,7 @@ package body Exp_Disp is
          --  Otherwise, count the primitives of the enclosing CPP type
 
          else
-            declare
-               Count : Nat := 0;
-               Elmt  : Elmt_Id;
-
-            begin
-               Elmt := First_Elmt (Primitive_Operations (CPP_Typ));
-               while Present (Elmt) loop
-                  Count := Count + 1;
-                  Next_Elmt (Elmt);
-               end loop;
-
-               return Count;
-            end;
+            return List_Length (Primitive_Operations (CPP_Typ));
          end if;
       end if;
    end CPP_Num_Prims;