Java > Scala
bearophile
bearophileHUGS at lycos.com
Thu Dec 1 05:29:23 PST 2011
David Eagen:
> I admit to being very new to D so perhaps I'm really doing something wrong.
This program uses string hashing, regular expressions, and by line file iteration. Those are among the most common operations done by script-like programs.
Some suggestions for your D code:
- Use the new regex engine
- Use File.byLine instead of BufferedFile
- don't use the built-in sort, use std.algorithm.sort
- try to minimize the number of memory allocations
- try to disable the GC if and when you think it's a good thing to do;
- avoid casts where possible.
- writef("%s,%d\n" ==> writefln("%s,%d"
For Phobos devs: is the new regex engine able to support verbose regexes (it means that allow newlines, empty space and even comments)? In practice I only use them in Python.
Bye,
bearophile
More information about the Digitalmars-d
mailing list