Minor performance optimization, but also hopefully makes the code more clean.
Currently when generation JSON representation of a message in order to calculate the ROS2 hash, we recursively generate the JSON for each referenced sub-message, and then discard these immedeatly.
This means the JSON representation for something like std_msgs/Header might be re-generated hundreds of times. Since codegen happens in macros this can cause IDE lag for users.
Instead we should store an Option on the Message type and store what is needed in there when it is calculated the first time. We shouldn't need to worry about "walking the graph" in a particular order.
Minor performance optimization, but also hopefully makes the code more clean.
Currently when generation JSON representation of a message in order to calculate the ROS2 hash, we recursively generate the JSON for each referenced sub-message, and then discard these immedeatly.
This means the JSON representation for something like std_msgs/Header might be re-generated hundreds of times. Since codegen happens in macros this can cause IDE lag for users.
Instead we should store an Option on the Message type and store what is needed in there when it is calculated the first time. We shouldn't need to worry about "walking the graph" in a particular order.