Snapchat / djinni

A tool for generating cross-language type declarations and interface bindings. Djinni's new home is in the Snapchat org.
Apache License 2.0
180 stars 50 forks source link

Support string_view for string constants in C++ #142

Open louiswins opened 1 year ago

louiswins commented 1 year ago

Right now djinni creates a static std::string const for each string constant. This adds a bunch of static initializers which perform allocations and copy data onto the heap. This increases startup times (static initializers run before main) when we could just reference that data directly in a constexpr std::string_view for free.

li-feng-sc commented 1 year ago

Hi @louiswins, right now Djinni uses std::string as the C++ side mapping of the string type. If we use string_view for constants, this means we will need to differentiate string constants and normal strings. This complicates things for both djinni itself and djinni users.