1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-12-04 14:46:47 -05:00

Drop zero-initialisation of static storage

In get_entity_string and point_intersect, do not initialise arrays with
static storage duration to zero; the C standard states that such objects
are automatically initialised to zero.
This commit is contained in:
Miciah Dashiel Butler Masters 2008-12-27 05:32:36 +00:00
parent aedc4c3e37
commit b9b2b75f73
2 changed files with 6 additions and 12 deletions

View File

@ -1067,10 +1067,12 @@ get_entity_string(const unsigned char *str, const int strlen, int encoding)
will go in [0] table */
static struct entity_cache entity_cache[ENTITY_CACHE_MAXLEN][ENTITY_CACHE_SIZE];
static unsigned int nb_entity_cache[ENTITY_CACHE_MAXLEN];
static int first_time = 1;
unsigned int slen = 0;
const unsigned char *result = NULL;
/* Note that an object of static storage duration is automatically
* initialised to zero in C. */
if (strlen <= 0) return NULL;
#ifdef CONFIG_UTF8
@ -1080,11 +1082,6 @@ get_entity_string(const unsigned char *str, const int strlen, int encoding)
goto skip;
#endif /* CONFIG_UTF8 */
if (first_time) {
memset(&nb_entity_cache, 0, ENTITY_CACHE_MAXLEN * sizeof(unsigned int));
first_time = 0;
}
/* Check if cached. A test on many websites (freshmeat.net + whole ELinks website
* + google + slashdot + websites that result from a search for test on google,
* + various ones) show quite impressive improvment:

View File

@ -889,16 +889,13 @@ point_intersect(struct point *p1, int l1, struct point *p2, int l2)
int i;
static char hash[HASH_SIZE];
static int first_time = 1;
/* Note that an object of static storage duration is automatically
* initialised to zero in C. */
assert(p2);
if_assert_failed return 0;
if (first_time) {
memset(hash, 0, HASH_SIZE);
first_time = 0;
}
for (i = 0; i < l1; i++) hash[HASH(p1[i])] = 1;
for (i = 0; i < l2; i++) {