Closed jalberse closed 4 months ago
I'm not overly concerned about this - this doesn't seem to be somewhere we spend a lot of time in rendering from profiling. Low priority. Might even not do this; lazy initialization might just be more ergonomic than any initialization logic.
I don't think this is actually something we want to do. I don't think it impacts performance, it's not in any hot loops I've seen. If it ever becomes an issue we can do it.
There's a few places, namely in colorspace and spectra conversions, where Lazy is used to read and initialize large data tables. But, each call to access that data during runtime incurs a check on if that data is initialized.
I had tried to use const functions to initialize the constants, but we want to initialize with some more complex dependent functions that aren't const themselves.
https://dev.to/rustyoctopus/generating-static-arrays-during-compile-time-in-rust-10d8
This article has some good discussion on this topic.
I think we might want to generate these constants via a build.rs script.