diff options
author | Christian Göttsche <cgzones@googlemail.com> | 2020-10-15 21:45:38 +0200 |
---|---|---|
committer | cgzones <cgzones@googlemail.com> | 2020-10-16 19:47:34 +0200 |
commit | e9246abff8010ec9a9624f004364a3851b6daad3 (patch) | |
tree | 5c71a7e117736c4864099932ceb750b285741007 /Vector.h | |
parent | a63cfc8b7c172aa7e849521a479d39af737681a8 (diff) |
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
Diffstat (limited to 'Vector.h')
-rw-r--r-- | Vector.h | 12 |
1 files changed, 8 insertions, 4 deletions
@@ -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 */ |