How are release builds so fast?

121 points maverickleopard

I’ve been working on replacing a C++ library that reads a ~250k line xml file. I want to replace it because it takes 3-4 seconds to do so and kills my iteration time.

I ended up as a first attempt writing my parser naively with nom (don’t ask me why I’m not using something like quick-xml). This took about the same time as the C++ library to run.

However, then i tried running a release build and it runs in 0.16-0.18s. This is great but I’m curious what sort of optimizations the compiler does on nom parsers that could result in this sort of speedup?

EDIT

The C++ program was compiled with -O3