Text format (e.g. IridasCube) parsing optimizations
Primarily driven by a wish to increase performance of parsing .cube files. But the functions that are added or changed are used across parsing of all/most of text based formats.
With these changes, parsing "Khronos PBR Neutral" Iridas .cube file (5.4MB) on Ryzen 5950X / VS2022 Release build: 167ms -> 126ms. Parsing the same file in CLF format: 150ms -> 137ms.
What the PR does is:
- Add locale independent
IsSpace(char). Somewhat similar to 3aab90d31, whitespace trimming perhaps should not be locale dependent. - Add
IsEmptyOrWhiteSpace()and use that insideParseUtils::nextline, instead of doingTrim(line).empty(). - Add
StringUtils::StartsWith(char)and use that in various parsers that were constructing wholestd::stringobject just to check for a single character. - When building for C++17 or later,
NumberUtilscan use standard<charconv>from_charsfunctions (except on Apple platforms, where those are not implemented for floating point types as of Xcode 15). This has advantage of not having to deal witherrnoor locales. Saves some thread local storage accesses and function calls (e.g. on Windowserrnois actually a function call).- Turns out that
NumberUtils::from_charswas only indirectly covered by tests, and as XML parser utils tests point out, it should be able to handle hex floats and so on. So all that is implemented there, and explicitly covered bytests/utils/NumberUtils_tests.cpp. - There's a CMake setup change that adds
/Zc:__cplusplusflag for MSVC; for backwards compat reasons it does not report proper C++ version detection defines otherwise.
- Turns out that
Apologies for the delay in CI @aras-p, we have to manually approve the workflows due to our current GitHub settings. Trying to see if we can update that or merge your other PR which should also work.
@remia thanks! I admit I did not expect that this PR would need so many failed iterations. <charconv> is a tough beast, it seems :)
Doing some test on an Intel MBP, Xcode 16, it seems to still not support from_chars()
Yeah, Apple's Clang/STL keeps on being "special". Some other software (e.g. Blender) works around this whole issue by embedding https://github.com/fastfloat/fast_float and using that instead of <charconv>
Now that two reviews have been done, is there something expected from my side to move forward with this PR?
@aras-p , apologies for the delay in getting this merged. Our CI system is currently having some problems which is causing checks to fail, but I don't think we will need you to do anything more on this one.
It's great to have your participation on OCIO -- we'll try to get your next PR merged more quickly! ;)