From: "Maciej W. Rozycki" <macro@embecosm.com>
To: gdb-patches@sourceware.org
Cc: Andrew Burgess <aburgess@redhat.com>
Subject: [PATCH 2/6] Avoid redundant operations in `fortran_array_walker'
Date: Sat, 11 Dec 2021 11:47:14 +0000 (GMT) [thread overview]
Message-ID: <alpine.DEB.2.20.2112092225040.10183@tpp.orcam.me.uk> (raw)
In-Reply-To: <alpine.DEB.2.20.2112091951250.10183@tpp.orcam.me.uk>
Move inner dimension's element type determination outside the respective
loops in `fortran_array_walker'. The operation is exactly the same with
each iteration, so there is no point in redoing it for each element and
while a smart compiler might be able to move it outside the loop it is
regardless a bad coding style. No functional change.
---
gdb/f-array-walker.h | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
gdb-fortran-array-walker-walk-type.diff
Index: src/gdb/f-array-walker.h
===================================================================
--- src.orig/gdb/f-array-walker.h
+++ src/gdb/f-array-walker.h
@@ -208,6 +208,8 @@ class fortran_array_walker
if (nss != m_ndimensions)
{
+ struct type *subarray_type = TYPE_TARGET_TYPE (check_typedef (type));
+
/* For dimensions other than the inner most, walk each element and
recurse while peeling off one more dimension of the array. */
for (LONGEST i = lowerbound;
@@ -218,13 +220,13 @@ class fortran_array_walker
LONGEST new_offset = offset + calc.index_offset (i);
/* Now print the lower dimension. */
- struct type *subarray_type
- = TYPE_TARGET_TYPE (check_typedef (type));
walk_1 (nss + 1, subarray_type, new_offset, (i == upperbound));
}
}
else
{
+ struct type *elt_type = check_typedef (TYPE_TARGET_TYPE (type));
+
/* For the inner most dimension of the array, process each element
within this dimension. */
for (LONGEST i = lowerbound;
@@ -233,7 +235,6 @@ class fortran_array_walker
{
LONGEST elt_off = offset + calc.index_offset (i);
- struct type *elt_type = check_typedef (TYPE_TARGET_TYPE (type));
if (is_dynamic_type (elt_type))
{
CORE_ADDR e_address = m_address + elt_off;
next prev parent reply other threads:[~2021-12-11 11:47 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-11 11:46 [PATCH 0/6] Make Fortran support respect more `set print' settings Maciej W. Rozycki
2021-12-11 11:47 ` [PATCH 1/6] Initialize `m_ndimensions' in the member initializer list Maciej W. Rozycki
2021-12-15 13:18 ` Andrew Burgess
2021-12-17 15:03 ` Maciej W. Rozycki
2021-12-11 11:47 ` Maciej W. Rozycki [this message]
2021-12-15 13:19 ` [PATCH 2/6] Avoid redundant operations in `fortran_array_walker' Andrew Burgess
2021-12-17 15:04 ` Maciej W. Rozycki
2021-12-11 11:47 ` [PATCH 3/6] Respect `set print repeats' with Fortran arrays Maciej W. Rozycki
2021-12-15 15:18 ` Andrew Burgess
2022-01-08 16:25 ` Maciej W. Rozycki
2021-12-11 11:47 ` [PATCH 4/6] Add `set print repeats' tests for C/C++ arrays Maciej W. Rozycki
2021-12-15 15:33 ` Andrew Burgess
2022-01-08 16:26 ` Maciej W. Rozycki
2021-12-11 11:47 ` [PATCH 5/6] Respect `set print array-indexes' with Fortran arrays Maciej W. Rozycki
2021-12-15 16:49 ` Andrew Burgess
2022-01-08 16:27 ` Maciej W. Rozycki
2021-12-11 11:48 ` [PATCH 6/6] Add `set print array-indexes' tests for C/C++ arrays Maciej W. Rozycki
2021-12-15 16:51 ` Andrew Burgess
2022-01-08 16:27 ` Maciej W. Rozycki
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=alpine.DEB.2.20.2112092225040.10183@tpp.orcam.me.uk \
--to=macro@embecosm.com \
--cc=aburgess@redhat.com \
--cc=gdb-patches@sourceware.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: link
Be 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).