Benchmark Dlang vs Node vs Ruby

Rene Zwanenburg via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri May 27 08:22:19 PDT 2016


On Friday, 27 May 2016 at 15:04:31 UTC, llaine wrote:
> My level of D is really slow, so can you help me to improve 
> this? :)

Here's an alternative getCompanies. Untested so it may contain 
some mistakes.

Company[] getCompanies() {
   auto conn = client.lockConnection();
   immutable result = conn.execStatement("SELECT id, name from 
companies LIMIT 10000", ValueFormat.TEXT);
   delete conn;

   import std.algorithm : map;
   import std.array : array;

   return result
     .rangify
     .map!(row => Company(row["id"].as!PGtext, 
row["name"].as!PGtext))
     .array;
}


More information about the Digitalmars-d-learn mailing list