lookuptable

Sebastiaan Koppe mail at skoppe.eu
Thu Apr 23 07:49:41 UTC 2020


On Thursday, 23 April 2020 at 04:29:12 UTC, Steven Schveighoffer 
wrote:
> Hm... thanks for the suggestion. I'm not sure if it fits here, 
> as the point is to avoid runtime cost and GC allocation, not 
> make lookups uber-fast.

Granted, it was far-fetched.

> These are meant to be short-lived things. My main target was 
> e.g. mysql-native has an "asAA" function which generates an AA 
> with keys being the column names. This is kind of crappy, 
> because if you do that for each row, then you are generating 
> and throwing away a LOT of data.

Yeah, that is quite crappy. I remember mapping each row to a 
struct and use member access, but then you have to sync the 
struct and the query yourself.

It doesn't have to be short-lived though. Most apps process the 
same set of queries, so pre-creating all your prepared statements 
and mappings might make sense. I am not sure about mysql, but 
postgres gives you back the columns and types after preparing a 
statement, so you could do some runtime mapping once at startup 
(and at each reconnect).


More information about the Digitalmars-d-announce mailing list