String Switch Lowering

H. S. Teoh hsteoh at quickfur.ath.cx
Thu Jan 25 19:05:08 UTC 2018


On Thu, Jan 25, 2018 at 11:42:03AM -0700, Jonathan M Davis via Digitalmars-d wrote:
> On Thursday, January 25, 2018 19:21:29 Benjamin Thaut via Digitalmars-d 
> wrote:
> > If we think this is a good idea, should we rewrite this particular
> > string switch to use a associative array instead to avoid the overly
> > long symbol name?
> 
> That particular switch statement is in a function that's deprecated
> and scheduled to be completely removed in about six months, so I don't
> see much point in worrying about it unless it's causing serious
> problems, and while that symbol name is stupidly long, AFAIK, it's not
> really causing any problems.

I haven't verified this yet, but I suspect that this may be (one of?)
the cause(s) of my recent woes with dmd's memory usage on low-memory
systems. If indeed this is the cause, then yes, it *is* causing problems
for me and anyone else who wants to use dmd on a low-memory system (this
sounds almost like an oxymoron these days!). And since it's deprecated,
perhaps it wouldn't hurt to hack it to use an AA instead so that in the
meantime Phobos doesn't consume inordinate amounts of memory just to
compile.


> I never would have thought that a switch statement would even have a
> symbol associated with it though. Clearly, I have no clue about how
> they're implemented.
[...]

IIRC they used to be a runtime function in druntime, but recently got
changed into a template, ostensibly for more flexibility in how they're
implemented. Apparently the original function was pretty lousy in terms
of performance. The new object.__switch is supposedly better, but the
expense of ridiculously-long symbols in the binary. Some days you just
can't win. :-/


T

-- 
Two wrongs don't make a right; but three rights do make a left...


More information about the Digitalmars-d mailing list