Table lookups - this is pretty definitive
JR
zorael at gmail.com
Tue Apr 1 12:35:19 PDT 2014
On Tuesday, 1 April 2014 at 18:35:50 UTC, Walter Bright wrote:
> immutable bool[256] tab2;
> static this()
> {
> for (size_t u = 0; u < 0x100; ++u)
> {
> tab2[u] = isIdentifierChar0(cast(ubyte)u);
> }
> }
Table lookups are awesome.
While tab2 there lends itself to being populated in a static
this() it would really lower the bar if we could define static
immutable AA literals at compile-time. Or at least CTFE-fill
them. Having to rely on static this() for such is unfortunate and
hacky.
Relevant is
http://forum.dlang.org/thread/oxnwtojtdymopgvanbwz@forum.dlang.org
in which I get a speed increase of >3.5x by doing string-to-enum
translation/mapping using someEnum[string] AA lookups, instead of
using someString.to!someEnum.
(Given CtAAs, std.conv.to could then generate such for various
translations where cheap -- assuming we still like AAs?)
More information about the Digitalmars-d
mailing list