Hacker News new | past | comments | ask | show | jobs | submit login

I had a 3 minute look at the code in the github repo.

The parser uses ~= (D's array concatenation operator) a lot. This always copies and will lead to quadratic performance for parsing e.g. blocks of statements. Similarly, the switch parser uses code like this:

    curStmts.length += 1;
    (*curStmts)[curStmts.length-1] = parseStmt(input);
This is similarly quadratic - it incrementally grows the statement array.

Look at algorithm performance first.




>This always copies and will lead to quadratic performance

In D, "a ~ b" always copies but "a ~= b" might not. Also, appending using ~= will grow the array exponentially, so the amoritized performance will be better than quadratic.

Doing "x.length += 1", however, does incremental growth and will have poor performance.

(See http://dlang.org/arrays.html and http://forum.dlang.org/post/op.wuic5nateav7ka@stevens-macboo... )




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: