You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently the StrawData constructor is reading the raw data fields into separate class variables (m_packetLength = readPacketLength()). The read methods are implemented in a very inefficient way (many branches instead of simple copy instructions). One should use a packed struct to directly access the fields. Something like following should do (I don't know the actual format, just guessing based on your code):
This way you have one single instruction (but two lines of code) to read the packetLength field.
Instead of reading all fields in the constructor one could check if directly accessing the packed struct is really slower then caching them. At least one should use larger data types like uint_fast8_t if caching is useful for class variables that are used very often.
Another way would be to implement the read methods with something like following (untested):
m_L0TriggerDecision = static_cast<uint8_t>(dataPointer+2);
The text was updated successfully, but these errors were encountered:
Currently the StrawData constructor is reading the raw data fields into separate class variables (m_packetLength = readPacketLength()). The read methods are implemented in a very inefficient way (many branches instead of simple copy instructions). One should use a packed struct to directly access the fields. Something like following should do (I don't know the actual format, just guessing based on your code):
To access the fields one can do following:
(STRAW_DATA_HDR*) hdr = static_cast<STRAW_DATA_HDR*>(dataPointer); m_packetLength = hdr->packetLength;
This way you have one single instruction (but two lines of code) to read the packetLength field.
Instead of reading all fields in the constructor one could check if directly accessing the packed struct is really slower then caching them. At least one should use larger data types like uint_fast8_t if caching is useful for class variables that are used very often.
Another way would be to implement the read methods with something like following (untested):
m_L0TriggerDecision = static_cast<uint8_t>(dataPointer+2);
The text was updated successfully, but these errors were encountered: