osmflat-rs
osmflat-rs copied to clipboard
Redundent transmute in osmflat_generated
Often times there are accessors that transmute the same time into itself such as:
https://github.com/boxdot/osmflat-rs/blob/011d70a90f784f8e60b1f4903e1367be454445d4/osmflat/src/osmflat_generated.rs#L494-L497
Is there any reason why this is being done, or is it something odd with the code generator? In this instance, the id is already an i64. Why transmute?
This is due to the generator supporting to deserialize enumerations: Those need to be transmuted. The generator could theoretically skip the useless transmute by checking if target type matches source type, but the way it was implemented right now it just always transmutes, even if it is a no-op.
I wonder if there is any performance hit?
Only in debug mode, release mode optimizes everything away. Similarly the flatdata_read_bytes macro is fully optimized to generate code similar to C++ bitfields.