From: Bob Duff Date: Mon, 25 Jan 2021 15:18:08 +0000 (-0500) Subject: [Ada] Minor efficiency improvement in containers X-Git-Tag: basepoints/gcc-13~7726 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=0e1e07728074a7162c8173abd10bc32e814ea254;p=thirdparty%2Fgcc.git [Ada] Minor efficiency improvement in containers gcc/ada/ * libgnat/a-conhel.adb (TC_Check): Move the Assert into the 'if'. --- diff --git a/gcc/ada/libgnat/a-conhel.adb b/gcc/ada/libgnat/a-conhel.adb index 60928451adb7..e7d82ac1636d 100644 --- a/gcc/ada/libgnat/a-conhel.adb +++ b/gcc/ada/libgnat/a-conhel.adb @@ -122,17 +122,20 @@ package body Ada.Containers.Helpers is procedure TC_Check (T_Counts : Tamper_Counts) is begin - if T_Check and then T_Counts.Busy > 0 then - raise Program_Error with - "attempt to tamper with cursors"; + if T_Check then + if T_Counts.Busy > 0 then + raise Program_Error with + "attempt to tamper with cursors"; + end if; + + -- The lock status (which monitors "element tampering") always + -- implies that the busy status (which monitors "cursor + -- tampering") is set too; this is a representation invariant. + -- Thus if the busy count is zero, then the lock count + -- must also be zero. + + pragma Assert (T_Counts.Lock = 0); end if; - - -- The lock status (which monitors "element tampering") always - -- implies that the busy status (which monitors "cursor tampering") - -- is set too; this is a representation invariant. Thus if the busy - -- bit is not set, then the lock bit must not be set either. - - pragma Assert (T_Counts.Lock = 0); end TC_Check; --------------