diff options
author | Patrick Palka <patrick@parcs.ath.cx> | 2013-06-26 10:21:06 -0400 |
---|---|---|
committer | Austin Seipp <aseipp@pobox.com> | 2013-07-06 17:21:36 -0500 |
commit | a5913a23bcade044e4c693f05e8a60605c8d5618 (patch) | |
tree | 3fa23095b8be61a32f086e266865d01589d49d28 /compiler/specialise/Specialise.lhs | |
parent | 405a20c671df30a977f72f6ee79a3dfc4dac60e5 (diff) | |
download | haskell-a5913a23bcade044e4c693f05e8a60605c8d5618.tar.gz |
Avoid needlessly splitting a UniqSupply when extracting a Unique (#8041)
In many places, 'splitUniqSupply' + 'uniqFromSupply' is used to split a
UniqSupply into a Unique and a new UniqSupply. In such places we should
instead use the more efficient and more appropriate
'takeUniqFromSupply' (or equivalent).
Not only is the former method slower, it also generates and throws away
an extra Unique.
Signed-off-by: Austin Seipp <aseipp@pobox.com>
Diffstat (limited to 'compiler/specialise/Specialise.lhs')
-rw-r--r-- | compiler/specialise/Specialise.lhs | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/compiler/specialise/Specialise.lhs b/compiler/specialise/Specialise.lhs index a161444d7b..bf73bec240 100644 --- a/compiler/specialise/Specialise.lhs +++ b/compiler/specialise/Specialise.lhs @@ -1882,6 +1882,12 @@ instance MonadUnique SpecM where put $ st { spec_uniq_supply = us2 } return us1 + getUniqueM + = SpecM $ do st <- get + let (u,us') = takeUniqFromSupply $ spec_uniq_supply st + put $ st { spec_uniq_supply = us' } + return u + instance HasDynFlags SpecM where getDynFlags = SpecM $ liftM spec_dflags get |