You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
std::string is used as a accumulator for the output string in GenerateText(...) in idl_gen_text.cpp. Each time one byte is added, the entire string is copied in a new container. At least internally a better way of handling this is probably to use std::ostream &_text as argument for GenStruct (in idl_gen_text.cpp), and wrap in GenerateText the call to GenStruct with
Although text.reserve(1024); is a nice trick for micro benchmarks, this output method will incur unexpected large execution times for larger outputs.
Another benefit of using std::ostream as function signature is should be rather easy to change the output routine so accept calls like GenerateText(..., std::cout) (avoiding composing the entire buffer in memory).