summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaciej W. Rozycki <macro@embecosm.com>2021-12-17 15:01:32 +0000
committerMaciej W. Rozycki <macro@embecosm.com>2021-12-17 15:01:32 +0000
commit8294c9025a901ad055c979f80815465765836ae1 (patch)
tree65a359308adb1e769184a6f165c4c5fd8a7a12fa
parentc12d6b570d929eabbe56160baaf85348b0fdf521 (diff)
downloadbinutils-gdb-8294c9025a901ad055c979f80815465765836ae1.tar.gz
Avoid redundant operations in `fortran_array_walker'
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.
-rw-r--r--gdb/f-array-walker.h7
1 files changed, 4 insertions, 3 deletions
diff --git a/gdb/f-array-walker.h b/gdb/f-array-walker.h
index 5f889e6924a..646f4cbe7be 100644
--- a/gdb/f-array-walker.h
+++ b/gdb/f-array-walker.h
@@ -208,6 +208,8 @@ private:
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 @@ private:
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 @@ private:
{
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;