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;
}

Reply via email to