From a94fd87b05aa23d453d6e238746b5a55e75544bd Mon Sep 17 00:00:00 2001 From: Benny Baumann Date: Tue, 17 Nov 2020 01:27:27 +0100 Subject: Avoid calling Object_isA from inside Vector_isConsistent --- Vector.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'Vector.c') diff --git a/Vector.c b/Vector.c index 721ebdd3..40e6203f 100644 --- a/Vector.c +++ b/Vector.c @@ -48,16 +48,16 @@ void Vector_delete(Vector* this) { static bool Vector_isConsistent(const Vector* this) { assert(this->items <= this->arraySize); + if (this->owner) { for (int i = 0; i < this->items; i++) { - if (this->array[i] && !Object_isA(this->array[i], this->type)) { + if (!this->array[i]) { return false; } } - return true; - } else { - return true; } + + return true; } unsigned int Vector_count(const Vector* this) { @@ -71,10 +71,10 @@ unsigned int Vector_count(const Vector* this) { return items; } -Object* Vector_get(Vector* this, int idx) { +Object* Vector_get(const Vector* this, int idx) { assert(idx >= 0 && idx < this->items); - assert(Vector_isConsistent(this)); assert(this->array[idx]); + assert(Object_isA(this->array[idx], this->type)); return this->array[idx]; } -- cgit v1.2.3