• qrczak's avatar
    [project @ 2001-04-14 22:27:00 by qrczak] · 8bd82b88
    qrczak authored
    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.
Array.lhs 4.4 KB