wichtounet / eddic

Compiler of the EDDI programming language
MIT License
33 stars 4 forks source link

removed the additional memory buffer for assembly files #2

Closed TyRoXx closed 12 years ago

TyRoXx commented 12 years ago

It is not necessary to use an std::stringstream as a memory buffer before touching the file stream. std::ostream does already buffer the data written to it in memory. I removed the stringstream and made the assembly generator write directly to the file stream.

The file stream is now explicitly flushed before assembling.

The hack for making small files work with nasm is no longer necessary. The real reason for the misbehaviour was that small files fit into the file stream's memory buffer and were therefore not written into the file until an explicit flush. As the file stream's destruction caused a flush after assembling, the problem was hardly observable.

I replaced many occurences of std::endl with '\n' because the former would also flush the file stream. On a stringstream the behaviour is equivalent.

The code is simpler now and preferring '\n' over endl is widely considered good practice.

wichtounet commented 12 years ago

Thanks a lot !

That's very good to have removed the ugly nasm hack. I didn't thought about flushing the stream... It is also better to avoid too many flushing.