mirror of
https://github.com/xzeldon/htop.git
synced 2025-07-12 12:14:36 +03:00
Misc Vector updates
- Move swap() macro to source file and implement as function - Implement Vector_get() and Vector_size() as inline functions to make them type safe and avoid lhs usage - Comment comparison statistics, they are only needed for performance testing
This commit is contained in:

committed by
cgzones

parent
a63cfc8b7c
commit
e9246abff8
12
Vector.h
12
Vector.h
@ -9,10 +9,9 @@ in the source distribution for its full text.
|
||||
|
||||
#include "Object.h"
|
||||
|
||||
#define swap(a_,x_,y_) do{ void* tmp_ = a_[x_]; a_[x_] = a_[y_]; a_[y_] = tmp_; }while(0)
|
||||
|
||||
#ifndef DEFAULT_SIZE
|
||||
#define DEFAULT_SIZE -1
|
||||
#define DEFAULT_SIZE (-1)
|
||||
#endif
|
||||
|
||||
typedef struct Vector_ {
|
||||
@ -54,8 +53,13 @@ int Vector_count(const Vector* this);
|
||||
|
||||
#else /* NDEBUG */
|
||||
|
||||
#define Vector_get(v_, idx_) ((v_)->array[idx_])
|
||||
#define Vector_size(v_) ((v_)->items)
|
||||
static inline Object* Vector_get(Vector* this, int idx) {
|
||||
return this->array[idx];
|
||||
}
|
||||
|
||||
static inline int Vector_size(const Vector* this) {
|
||||
return this->items;
|
||||
}
|
||||
|
||||
#endif /* NDEBUG */
|
||||
|
||||
|
Reference in New Issue
Block a user