Don't init array at run time

When it can be done at compile time.

	* mmo.c (valid_mmo_symbol_character_set): Initialize and make
	array const.
	(mmo_init): Don't init valid_mmo_symbol_character_set.
This commit is contained in:
Alan Modra 2018-08-20 09:25:12 +09:30
parent d203b41ac7
commit 865dcc8a4d
2 changed files with 30 additions and 27 deletions

View File

@ -1,3 +1,9 @@
2018-08-20 Alan Modra <amodra@gmail.com>
* mmo.c (valid_mmo_symbol_character_set): Initialize and make
array const.
(mmo_init): Don't init valid_mmo_symbol_character_set.
2018-08-20 Alan Modra <amodra@gmail.com>
* rs6000-core.c (CORE_COMMONSZ): Balance parentheses in expression.

View File

@ -431,22 +431,30 @@ static bfd_boolean mmo_write_section_description (bfd *, asection *);
static bfd_boolean mmo_has_leading_or_trailing_zero_tetra_p (bfd *,
asection *);
/* Global "const" variables initialized once. Must not depend on
particular input or caller; put such things into the bfd or elsewhere.
Look ma, no static per-invocation data! */
static
char valid_mmo_symbol_character_set[/* A-Z a-z (we assume consecutive
codes; sorry EBCDIC:ers!). */
+ 'Z' - 'A' + 1 + 'z' - 'a' + 1
/* Digits. */
+ 10
/* ':' and '_'. */
+ 1 + 1
/* Codes higher than 126. */
+ 256 - 126
/* Ending zero. */
+ 1];
static const char
valid_mmo_symbol_character_set[] =
{
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',
'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm',
'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
':', '_', 126, 127, 128, 129,
130, 131, 132, 133, 134, 135, 136, 137, 138, 139,
140, 141, 142, 143, 144, 145, 146, 147, 148, 149,
150, 151, 152, 153, 154, 155, 156, 157, 158, 159,
160, 161, 162, 163, 164, 165, 166, 167, 168, 169,
170, 171, 172, 173, 174, 175, 176, 177, 178, 179,
180, 181, 182, 183, 184, 185, 186, 187, 188, 189,
190, 191, 192, 193, 194, 195, 196, 197, 198, 199,
200, 201, 202, 203, 204, 205, 206, 207, 208, 209,
210, 211, 212, 213, 214, 215, 216, 217, 218, 219,
220, 221, 222, 223, 224, 225, 226, 227, 228, 229,
230, 231, 232, 233, 234, 235, 236, 237, 238, 239,
240, 241, 242, 243, 244, 245, 246, 247, 248, 249,
250, 251, 252, 253, 254, 255,
0
};
/* Get section SECNAME or create one if it doesn't exist. When creating
@ -484,21 +492,10 @@ static void
mmo_init (void)
{
static bfd_boolean inited = FALSE;
int i = 0;
int j = 0;
static const char letters[]
= "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789:_";
if (inited)
return;
inited = TRUE;
/* Fill in the set of valid symbol characters. */
strcpy (valid_mmo_symbol_character_set, letters);
i = strlen (letters);
for (j = 126; j < 256; j++)
valid_mmo_symbol_character_set[i++] = j;
}
/* Check whether an existing file is an mmo file. */