From a387f73aa7a6095602170f2cb580e7525e642c64 Mon Sep 17 00:00:00 2001 From: tetektoza Date: Sat, 14 Oct 2023 01:54:05 +0200 Subject: [PATCH] Refactor: simplify logic in items.h Currently some of the "isItem" functions add an unnecessary check of isEmpty which is redundant, because a few lines lower they also check for item type inside the same object. This patch removes those unnecessary checks. --- Source/items.h | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/Source/items.h b/Source/items.h index 35a1b99d8..d1d688c15 100644 --- a/Source/items.h +++ b/Source/items.h @@ -303,10 +303,6 @@ struct Item { */ bool isWeapon() const { - if (this->isEmpty()) { - return false; - } - switch (this->_itype) { case ItemType::Axe: case ItemType::Bow: @@ -326,10 +322,6 @@ struct Item { */ bool isArmor() const { - if (this->isEmpty()) { - return false; - } - switch (this->_itype) { case ItemType::HeavyArmor: case ItemType::LightArmor: @@ -347,7 +339,7 @@ struct Item { */ bool isHelm() const { - return !this->isEmpty() && this->_itype == ItemType::Helm; + return this->_itype == ItemType::Helm; } /** @@ -356,7 +348,7 @@ struct Item { */ bool isShield() const { - return !this->isEmpty() && this->_itype == ItemType::Shield; + return this->_itype == ItemType::Shield; } /** @@ -365,10 +357,6 @@ struct Item { */ bool isJewelry() const { - if (this->isEmpty()) { - return false; - } - switch (this->_itype) { case ItemType::Amulet: case ItemType::Ring: