[project @ 2001-04-14 22:27:00 by qrczak]
authorqrczak <unknown>
Sat, 14 Apr 2001 22:27:00 +0000 (22:27 +0000)
committerqrczak <unknown>
Sat, 14 Apr 2001 22:27:00 +0000 (22:27 +0000)
commit8bd82b8898218c6285c4b23cb37c13a220cc5d2b
tree2257955211ec29983bab0fee5f7cac60fb22ea4a
parent940d9d970d9d824413f2776faf0f6cbd3f033f91
[project @ 2001-04-14 22:27:00 by qrczak]
Implementation of arrays rewritten
----------------------------------

Bulk operations like listArray, elems, fmap/amap, (==), getElems,
getAssocs, freeze etc. no longer check whether indices which are
not provided by the programmer are in bounds (they always are), and
avoid unnecessary translation between Ix indices and Int indices.
Some operations are implemented more efficiently, most notably (==)
and compare.

This applies to all IArray and MArray instances, including Haskell
98 Arrays.

Old methods of IArray and MArray are now functions; this is the only
change in the interface. New methods are exported only by ArrayBase,
i.e. not officially exported. They work on Int indices and are unsafe:
they don't do bounds checks themselves. Public functions do checks
and index translation instead where necessary.

More is inlined, to ensure that anything worth specialization or list
fusion gets specialized and fused. Perhaps a bit too much is inlined.
If it was possible to say that a function should be instantiated in
other modules for each type but not inlined on each use, it would be
useful here.

Using UArray Int Char wrapped in a nice interface (not included
here) instead of PackedString should be reasonable. PackedStrings
are 10% faster than UArray in a sorting test (and don't support
Unicode). Standard Strings are 50% slower (and take up more memory),
even though other test versions convert input from standard Strings
and convert output to them. ByteArrays tuned by hand for the benchmark
are 15% faster. The same UArray test compiled with released ghc-5.00,
with compare defined in terms of assocs, is 7 times slower.
ghc/lib/std/Array.lhs
ghc/lib/std/PrelArr.lhs