summaryrefslogtreecommitdiffstats
path: root/src/vppinfra
diff options
context:
space:
mode:
authorDave Barach <dave@barachs.net>2019-05-10 15:25:10 -0400
committerFlorin Coras <florin.coras@gmail.com>2019-05-14 17:50:35 +0000
commit2180baccc1428ffbd64a8312f3c983791a0771ab (patch)
treedee36722337e21f753c315768d34367531f0af1d /src/vppinfra
parent5e8e8dcd71c619b098093e124ccde89ba3590e6f (diff)
Preallocate mhash key_tmps vector
Fix os_get_nthreads() so that it starts returning the correct answer as early as possible. Change-Id: Id5292262f2c3f521b07ffbe6a9f6748dcc4dcb7d Signed-off-by: Dave Barach <dave@barachs.net>
Diffstat (limited to 'src/vppinfra')
-rw-r--r--src/vppinfra/mhash.c9
1 files changed, 1 insertions, 8 deletions
diff --git a/src/vppinfra/mhash.c b/src/vppinfra/mhash.c
index d4d5457ea7a..791aa36024b 100644
--- a/src/vppinfra/mhash.c
+++ b/src/vppinfra/mhash.c
@@ -205,13 +205,7 @@ mhash_init (mhash_t * h, uword n_value_bytes, uword n_key_bytes)
clib_memset (h, 0, sizeof (h[0]));
h->n_key_bytes = n_key_bytes;
-#if 0
- if (h->n_key_bytes > 0)
- {
- vec_validate (h->key_tmp, h->n_key_bytes - 1);
- _vec_len (h->key_tmp) = 0;
- }
-#endif
+ vec_validate (h->key_tmps, os_get_nthreads () - 1);
ASSERT (n_key_bytes < ARRAY_LEN (t));
h->hash = hash_create2 ( /* elts */ 0,
@@ -228,7 +222,6 @@ mhash_set_tmp_key (mhash_t * h, const void *key)
u8 *key_tmp;
int my_cpu = os_get_thread_index ();
- vec_validate (h->key_tmps, my_cpu);
key_tmp = h->key_tmps[my_cpu];
vec_reset_length (key_tmp);