From 903666a6027cec25010a99c05824df14ce26e7bf Mon Sep 17 00:00:00 2001 From: Ivan Komissarov Date: Sun, 21 Oct 2018 12:18:25 +0200 Subject: qtriangulator: Remove a bunch of dead code There is no sense in testing the 'm_array' pointer against null, as the memory was allocated using the 'new' operator. The exception will be generated in the case of memory allocation error. Task-number: QTBUG-71156 Change-Id: Ib76d16d38d2b0b0c4c9fae3d8d5bdd86af0d08ff Reviewed-by: Thiago Macieira --- src/gui/painting/qtriangulator.cpp | 30 ++++++++---------------------- 1 file changed, 8 insertions(+), 22 deletions(-) (limited to 'src') diff --git a/src/gui/painting/qtriangulator.cpp b/src/gui/painting/qtriangulator.cpp index 6d57eba123..9be3eeaffd 100644 --- a/src/gui/painting/qtriangulator.cpp +++ b/src/gui/painting/qtriangulator.cpp @@ -472,7 +472,7 @@ class QInt64Set { public: inline QInt64Set(int capacity = 64); - inline ~QInt64Set() {if (m_array) delete[] m_array;} + inline ~QInt64Set() {delete[] m_array;} inline bool isValid() const {return m_array;} void insert(quint64 key); bool contains(quint64 key) const; @@ -493,10 +493,7 @@ inline QInt64Set::QInt64Set(int capacity) { m_capacity = primeForCount(capacity); m_array = new quint64[m_capacity]; - if (m_array) - clear(); - else - m_capacity = 0; + clear(); } bool QInt64Set::rehash(int capacity) @@ -506,28 +503,19 @@ bool QInt64Set::rehash(int capacity) m_capacity = capacity; m_array = new quint64[m_capacity]; - if (m_array) { - clear(); - if (oldArray) { - for (int i = 0; i < oldCapacity; ++i) { - if (oldArray[i] != UNUSED) - insert(oldArray[i]); - } - delete[] oldArray; - } - return true; - } else { - m_capacity = oldCapacity; - m_array = oldArray; - return false; + clear(); + for (int i = 0; i < oldCapacity; ++i) { + if (oldArray[i] != UNUSED) + insert(oldArray[i]); } + delete[] oldArray; + return true; } void QInt64Set::insert(quint64 key) { if (m_count > 3 * m_capacity / 4) rehash(primeForCount(2 * m_capacity)); - Q_ASSERT_X(m_array, "QInt64Hash::insert", "Hash set not allocated."); int index = int(key % m_capacity); for (int i = 0; i < m_capacity; ++i) { index += i; @@ -546,7 +534,6 @@ void QInt64Set::insert(quint64 key) bool QInt64Set::contains(quint64 key) const { - Q_ASSERT_X(m_array, "QInt64Hash::contains", "Hash set not allocated."); int index = int(key % m_capacity); for (int i = 0; i < m_capacity; ++i) { index += i; @@ -562,7 +549,6 @@ bool QInt64Set::contains(quint64 key) const inline void QInt64Set::clear() { - Q_ASSERT_X(m_array, "QInt64Hash::clear", "Hash set not allocated."); for (int i = 0; i < m_capacity; ++i) m_array[i] = UNUSED; m_count = 0; -- cgit v1.2.3