There's a number of places where we voluntarily use std::function to hold callbacks (as opposed to e.g. JSI where usage is forced). This is sub-optimal from a binary size perspective since std::function prevents a lot of things from getting folded together. The root problem seems to be std::function's target_type and target functions. These require the object to hold RTTI info on the underlying function object - even though I've never seen or heard of anyone needing/wanting these functions - which then causes constructors & v-tables to need to be unique causing a whole host of functions to be non-foldable.
It would be relatively simple to substitute in our own std::function-like type that does not require this RTTI info, though it's not immediately clear if it would be worth it. Could be a good investigation, though.
There's a number of places where we voluntarily use
std::functionto hold callbacks (as opposed to e.g. JSI where usage is forced). This is sub-optimal from a binary size perspective sincestd::functionprevents a lot of things from getting folded together. The root problem seems to bestd::function'starget_typeandtargetfunctions. These require the object to hold RTTI info on the underlying function object - even though I've never seen or heard of anyone needing/wanting these functions - which then causes constructors & v-tables to need to be unique causing a whole host of functions to be non-foldable.It would be relatively simple to substitute in our own
std::function-like type that does not require this RTTI info, though it's not immediately clear if it would be worth it. Could be a good investigation, though.