4 ms·
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 quadrati
by barrkel 12y ago
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.
- edmccard 12y ago>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 http://dlang.org/arrays.html and http://forum.dlang.org/post/op.wuic5nateav7ka@stevens-macbook-pro.local http://forum.dlang.org/post/op.wuic5nateav7ka@stevens-macboo... )
- deleted 12y ago[deleted]