djrieger / mjplusplus

A compiler for the MiniJava language
http://djrieger.github.io/mjplusplus/doc/doxygen/html/
6 stars 1 forks source link

More efficient ast printer #6

Closed ratefuchs closed 9 years ago

ratefuchs commented 9 years ago

Currently, each toString() method gets the indentation depth as parameter, with each statement generating its indentation string by itself. This seems to be very inefficient (quadratic in nesting depth). It would be better to give the ident string itself to the child toString() functions (with each indentation inducing statement adding one tab for the child calls).

Nidan commented 9 years ago

while this might create some runtime cost, the worst offender is something else...