From c82fb93476b9c32698f8c069e631d94fd6458666 Mon Sep 17 00:00:00 2001 From: Sylvain Henry Date: Fri, 11 Mar 2022 16:47:20 +0100 Subject: Hadrian: avoid allocations in WayUnit's Read instance (#19209) --- hadrian/src/Way/Type.hs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/hadrian/src/Way/Type.hs b/hadrian/src/Way/Type.hs index 4055ff4798..257fce8c47 100644 --- a/hadrian/src/Way/Type.hs +++ b/hadrian/src/Way/Type.hs @@ -27,8 +27,15 @@ instance Show WayUnit where Logging -> "l" Dynamic -> "dyn" +-- TODO: get rid of non-derived Read instance instance Read WayUnit where - readsPrec _ s = [(unit, "") | unit <- [minBound ..], show unit == s] + readsPrec _ = \case + "thr" -> [(Threaded,"")] + "debug" -> [(Debug,"")] + "p" -> [(Profiling,"")] + "l" -> [(Logging,"")] + "dyn" -> [(Dynamic,"")] + _ -> [] -- | Collection of 'WayUnit's that stands for the different ways source code -- is to be built. -- cgit v1.2.1