diff options
author | David Lamparter <equinox@opensourcerouting.org> | 2021-10-18 15:29:17 +0200 |
---|---|---|
committer | David Lamparter <equinox@opensourcerouting.org> | 2021-10-18 19:48:11 +0200 |
commit | 14c39974bbb37a1c95800b75af3d25ff72295f41 (patch) | |
tree | 35f2ead810582e664df3088e941954277a72798b /lib/vector.h | |
parent | vtysh: defer CLI tree building (diff) | |
download | frr-14c39974bbb37a1c95800b75af3d25ff72295f41.tar.xz frr-14c39974bbb37a1c95800b75af3d25ff72295f41.zip |
lib: keep element count in vector code
... to speed up vector_empty_slot() among other things.
Behavior should be 100% identical to previous.
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
Diffstat (limited to '')
-rw-r--r-- | lib/vector.h | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/vector.h b/lib/vector.h index 845c8d8b0..6208be1cc 100644 --- a/lib/vector.h +++ b/lib/vector.h @@ -32,6 +32,7 @@ extern "C" { struct _vector { unsigned int active; /* number of active slots */ unsigned int alloced; /* number of allocated slot */ + unsigned int count; void **index; /* index to data */ }; typedef struct _vector *vector; @@ -60,7 +61,11 @@ extern void vector_unset_value(vector v, void *val); extern void vector_remove(vector v, unsigned int ix); extern void vector_compact(vector v); -extern unsigned int vector_count(vector v); +static inline unsigned int vector_count(vector v) +{ + return v->count; +} + extern void vector_free(vector v); extern vector vector_copy(vector v); |