public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Pierre-Marie de Rodat <pmderodat@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc r12-1518] [Ada] Cleanup repeated calls in Sloc_Range Date: Wed, 16 Jun 2021 08:45:54 +0000 (GMT) [thread overview] Message-ID: <20210616084554.57A32398B155@sourceware.org> (raw) https://gcc.gnu.org/g:207962b929cc771fd560c467f44efe8f9f679ac4 commit r12-1518-g207962b929cc771fd560c467f44efe8f9f679ac4 Author: Piotr Trojanek <trojanek@adacore.com> Date: Wed Mar 3 11:45:41 2021 +0100 [Ada] Cleanup repeated calls in Sloc_Range gcc/ada/ * sinput.adb (Sloc_Range): Refactor several repeated calls to Sloc and two comparisons with No_Location. Diff: --- gcc/ada/sinput.adb | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/gcc/ada/sinput.adb b/gcc/ada/sinput.adb index df61856d57c..e62bf4565e1 100644 --- a/gcc/ada/sinput.adb +++ b/gcc/ada/sinput.adb @@ -933,7 +933,7 @@ package body Sinput is procedure Sloc_Range (N : Node_Id; Min, Max : out Source_Ptr) is - Indx : constant Source_File_Index := Get_Source_File_Index (Sloc (N)); + Indx : constant Source_File_Index := Get_Source_File_Index (Sloc (N)); function Process (N : Node_Id) return Traverse_Result; -- Process function for traversing the node tree @@ -945,25 +945,22 @@ package body Sinput is ------------- function Process (N : Node_Id) return Traverse_Result is - Orig : constant Node_Id := Original_Node (N); + Loc : constant Source_Ptr := Sloc (Original_Node (N)); begin -- Skip nodes that may have been added during expansion and -- that originate in other units, such as code for contracts -- in subprogram bodies. - if Get_Source_File_Index (Sloc (Orig)) /= Indx then + if Get_Source_File_Index (Loc) /= Indx then return Skip; end if; - if Sloc (Orig) < Min then - if Sloc (Orig) > No_Location then - Min := Sloc (Orig); - end if; - - elsif Sloc (Orig) > Max then - if Sloc (Orig) > No_Location then - Max := Sloc (Orig); + if Loc > No_Location then + if Loc < Min then + Min := Loc; + elsif Loc > Max then + Max := Loc; end if; end if; @@ -974,7 +971,7 @@ package body Sinput is begin Min := Sloc (N); - Max := Sloc (N); + Max := Min; Traverse (N); end Sloc_Range;
reply other threads:[~2021-06-16 8:45 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20210616084554.57A32398B155@sourceware.org \ --to=pmderodat@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).