Skip to content

Data.Array.Base.elems needlessly calls bounds.

elems arr = case bounds arr of
    (_l, _u) -> [unsafeAt arr i | i <- [0 .. numElements arr - 1]]

It never uses the result.

I'd propose simplifying it to

elems arr = [unsafeAt arr i | i <- [0 .. numElements arr - 1]]

It appears at some point someone optimized it to use the unsafeAt, but never removed the bounds check.

Trac metadata
Trac field Value
Version 7.8.4
Type FeatureRequest
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Core Libraries
Test case
Differential revisions
BlockedBy
Related
Blocking
CC core-libraries-committee@haskell.org
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information