From e9246abff8010ec9a9624f004364a3851b6daad3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20G=C3=B6ttsche?= Date: Thu, 15 Oct 2020 21:45:38 +0200 Subject: 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 --- Vector.h | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'Vector.h') diff --git a/Vector.h b/Vector.h index 491779b3..428b931d 100644 --- a/Vector.h +++ b/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 */ -- cgit v1.2.3