[improve-it] Parsing NG archive and sorting by post-count

bearophile bearophileHUGS at lycos.com
Tue Mar 15 15:38:18 PDT 2011


Andrej Mitrovic:

> I've also implemented an `allSatisfy` function which works on runtime arguments. There's a similar function in std.typetuple, but its only useful for compile-time arguments. There's probably a similar method someplace in std.algorithm, but I was too lazy to check. I thought it would be nice to have.

http://d.puremagic.com/issues/show_bug.cgi?id=4405


> Anywho, let's see you improve my code! It's just for fun and maybe we'll learn some tricks from one another. Have fun!

I suggest you to add unit tests and Contracts to your CommonAA() and allSatisfy() :-)

Have you tried to replace this:

        if (key in payload)
        {
            payload[key] ~= val;
        }
        else
        {
            payload[key] = [val];
        }

With just:

        payload[key] ~= val;


I suggest to replace this:
sortedKeys.sort;

With:
sortedKeys.sort();

Bye,
bearophile


More information about the Digitalmars-d-learn mailing list