aboutsummaryrefslogtreecommitdiff
path: root/src/Data/Array
diff options
context:
space:
mode:
authorTom Smeding <tom@tomsmeding.com>2025-12-03 20:55:40 +0100
committerTom Smeding <tom@tomsmeding.com>2025-12-03 20:55:40 +0100
commit13a0ad5e2938218dd97c8db49b3da6c5bdd5a5db (patch)
treec3ea397db87612463901a5c4a8fef471236858e2 /src/Data/Array
parentfabab15e38f752bc98008a350e9817819ed0801a (diff)
Inlining magicHEADmaster
Diffstat (limited to 'src/Data/Array')
-rw-r--r--src/Data/Array/Nested/Mixed/Shape/Internal.hs8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/Data/Array/Nested/Mixed/Shape/Internal.hs b/src/Data/Array/Nested/Mixed/Shape/Internal.hs
index 9997b0f..2a86ac1 100644
--- a/src/Data/Array/Nested/Mixed/Shape/Internal.hs
+++ b/src/Data/Array/Nested/Mixed/Shape/Internal.hs
@@ -20,9 +20,11 @@ ixFromLinearStub fname' ishty ixty zshC consshC ixz ixcons shtolist = do
locals <- [d|
-- Unfold first iteration of fromLin to do the range check.
- -- Don't inline because if this is inlined, GHC seems to stop sharing
- -- 'suffixes' over multiple calls, which breaks performance in sh*Enum.
- {-# NOINLINE fromLin0 #-}
+ -- Don't inline this function at first to allow GHC to inline the outer
+ -- function and realise that 'suffixes' is shared. But then later inline it
+ -- anyway, to avoid the function call. Removing the pragma makes GHC
+ -- somehow unable to recognise that 'suffixes' can be shared in a loop.
+ {-# NOINLINE [0] fromLin0 #-}
fromLin0 :: Num i => $ishty sh -> [Int] -> Int -> $ixty sh i
fromLin0 sh suffixes i =
if i < 0 then outrange sh i else