aboutsummaryrefslogtreecommitdiffstats
path: root/src/vppinfra/sparse_vec.h
diff options
context:
space:
mode:
authorDamjan Marion <damarion@cisco.com>2022-04-11 18:41:49 +0200
committerFlorin Coras <florin.coras@gmail.com>2022-04-12 22:40:52 +0000
commite4fa1d2f6b8721318c0f104f2615588b5d4e0441 (patch)
tree70d33a24bae0b9aa993fe6e03960e2b135accb70 /src/vppinfra/sparse_vec.h
parent65e770d895b13a6e5c73d13f436872ea626e47e3 (diff)
vppinfra: vector perf improvements
Type: improvement Change-Id: I37c187af80c21b8fb1ab15af112527a837e0df9e Signed-off-by: Damjan Marion <damarion@cisco.com>
Diffstat (limited to 'src/vppinfra/sparse_vec.h')
-rw-r--r--src/vppinfra/sparse_vec.h7
1 files changed, 3 insertions, 4 deletions
diff --git a/src/vppinfra/sparse_vec.h b/src/vppinfra/sparse_vec.h
index dc9cb00380a..1f57d304e95 100644
--- a/src/vppinfra/sparse_vec.h
+++ b/src/vppinfra/sparse_vec.h
@@ -73,15 +73,14 @@ sparse_vec_new (uword elt_bytes, uword sparse_index_bits)
void *v;
sparse_vec_header_t *h;
word n;
+ vec_attr_t va = { .elt_sz = elt_bytes, .hdr_sz = sizeof (h[0]) };
ASSERT (sparse_index_bits <= 16);
- v = _vec_realloc (0, /* data bytes */ 8, elt_bytes,
- /* header bytes */ sizeof (h[0]), /* data align */ 0,
- /* heap */ 0);
+ v = _vec_alloc_internal (/* data bytes */ 8, &va);
/* Make space for invalid entry (entry 0). */
- _vec_find (v)->len = 1;
+ _vec_set_len (v, 1, elt_bytes);
h = sparse_vec_header (v);