From 03032c91c2fc48acab08314b8e43c7d963e5e65c Mon Sep 17 00:00:00 2001 From: Sarah Ashri Date: Wed, 13 Mar 2024 10:20:55 +1000 Subject: [PATCH] extracted LegendaryItems processing from if statements in DailyItemUpdate LegendayItems don't change and therefore, can return immediately --- csharpcore/GildedRose/GildedRose.cs | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/csharpcore/GildedRose/GildedRose.cs b/csharpcore/GildedRose/GildedRose.cs index 6f7170f3..1ad95035 100644 --- a/csharpcore/GildedRose/GildedRose.cs +++ b/csharpcore/GildedRose/GildedRose.cs @@ -32,14 +32,13 @@ public class GildedRose private void DailyItemUpdate(Item item) { + if (IsLegendaryItem(item)) return; + if (!IsBetterWithAgeItem(item) && !IsBackstagePassesItem(item)) { if (item.Quality > MinQuality) { - if (!IsLegendaryItem(item)) - { - item.Quality = item.Quality - 1; - } + item.Quality = item.Quality - 1; } } else @@ -69,11 +68,8 @@ public class GildedRose } } - if (!IsLegendaryItem(item)) - { - item.SellIn = item.SellIn - 1; - } - + item.SellIn = item.SellIn - 1; + if (item.SellIn < 0) { if (!IsBetterWithAgeItem(item)) @@ -82,10 +78,7 @@ public class GildedRose { if (item.Quality > MinQuality) { - if (!IsLegendaryItem(item)) - { - item.Quality = item.Quality - 1; - } + item.Quality = item.Quality - 1; } } else