diff options
author | Bob Duff <duff@adacore.com> | 2021-01-25 10:18:08 -0500 |
---|---|---|
committer | Pierre-Marie de Rodat <derodat@adacore.com> | 2021-05-07 05:28:54 -0400 |
commit | 0e1e07728074a7162c8173abd10bc32e814ea254 (patch) | |
tree | 9dc5101544554b877ef1135a9b330834b85cfdfb | |
parent | f015e33fc4cac3ee7f11aceb08f5d76b1b588111 (diff) | |
download | gcc-0e1e07728074a7162c8173abd10bc32e814ea254.zip gcc-0e1e07728074a7162c8173abd10bc32e814ea254.tar.gz gcc-0e1e07728074a7162c8173abd10bc32e814ea254.tar.bz2 |
[Ada] Minor efficiency improvement in containers
gcc/ada/
* libgnat/a-conhel.adb (TC_Check): Move the Assert into the
'if'.
-rw-r--r-- | gcc/ada/libgnat/a-conhel.adb | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/gcc/ada/libgnat/a-conhel.adb b/gcc/ada/libgnat/a-conhel.adb index 6092845..e7d82ac 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; -------------- |