diff options
author | Tom Tromey <tom@tromey.com> | 2021-12-03 14:45:37 -0700 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2021-12-08 13:20:30 -0700 |
commit | 696d6f4d5c1bc9b36d0402c2393efe62e49392d9 (patch) | |
tree | e0a5c7edfce36b065afc1f443a15906936c44660 /gdb/bcache.c | |
parent | 621f8c42d3df079ca5781cdb0925c5ec3498f59c (diff) | |
download | binutils-gdb-696d6f4d5c1bc9b36d0402c2393efe62e49392d9.tar.gz |
Use for-each more in gdb
There are some loops in gdb that use ARRAY_SIZE (or a wordier
equivalent) to loop over a static array. This patch changes some of
these to use foreach instead.
Regression tested on x86-64 Fedora 34.
Diffstat (limited to 'gdb/bcache.c')
-rw-r--r-- | gdb/bcache.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/gdb/bcache.c b/gdb/bcache.c index b7be9676271..ae43853adaa 100644 --- a/gdb/bcache.c +++ b/gdb/bcache.c @@ -68,7 +68,7 @@ bcache::expand_hash_table () so we roughly double the table size each time. After we fall off the end of this table, we just double. Don't laugh --- there have been executables sighted with a gigabyte of debug info. */ - static unsigned long sizes[] = { + static const unsigned long sizes[] = { 1021, 2053, 4099, 8191, 16381, 32771, 65537, 131071, 262144, 524287, 1048573, 2097143, 4194301, 8388617, 16777213, 33554467, 67108859, 134217757, @@ -85,10 +85,10 @@ bcache::expand_hash_table () /* Find the next size. */ new_num_buckets = m_num_buckets * 2; - for (i = 0; i < (sizeof (sizes) / sizeof (sizes[0])); i++) - if (sizes[i] > m_num_buckets) + for (unsigned long a_size : sizes) + if (a_size > m_num_buckets) { - new_num_buckets = sizes[i]; + new_num_buckets = a_size; break; } |