Array append performance

dsimcha dsimcha at yahoo.com
Sat Aug 23 20:33:43 PDT 2008


== Quote from Bill Baxter (wbaxter at gmail.com)'s article
> Personally I'd argue that appending efficiently is important to more
> programs than than saving 4-8 bytes here and there.  So that would
> suggest that lean-and-mean fixed-sized arrays should be the library
> solution, and arrays with a capacity field should be the built-in
> type.
> --bb

Definitely a reasonable argument, but just to play devil's advocate, let's assume
that opImplicitCast is coming eventually.  Most of the library implementations of
arrays will presumably be implicitly castable to builtins, and library functions,
especially standard lib functions, will probably use the builtin type as
arguments.  Implicit casting to builtin, in my view, is essential to using library
implementations of arrays, because otherwise you have a mess of a zillion
different incompatible array library implementations a la C++.  If you have to
create a dummy capacity field every time you implicitly cast your array to a
builtin anyhow, that might defeat the purpose of a lightweight library
implementation at times.



More information about the Digitalmars-d mailing list