3 ms·
Will you be able to disable bounds checking in a production version and/or move it to a once only for the entire object model?
by alexchamberlain 14y ago
Will you be able to disable bounds checking in a production version and/or move it to a once only for the entire object model?
- kentonv 14y agoYes! If you really, truly trust your input data, and it is in a single flat array, you can call capnproto::readRootTrusted<MyType>(ptr) instead of setting up a MessageReader. All bounds checks and other validation will be skipped. But, IMO this is only a good idea for, like, static constants embedded into the source code. Anything you read dynamically could be corrupted if not malicious, and you don't want that to kill your server. That's up to you, though.
- alexchamberlain 14y agoAgreed that bounds checking is the correct default here, but it's nice to know that in true C++ fashion we can shoot our leg off if we so choose.