It is getting too complicated for search of one out of 40. You can do it many times over and many ways at once and it will not matter in terms of performance.
Check if search is even necessary. Many API assign index to your request or have other specific integer ID attached to returned contract data and you may use it to directly index to your struct using just that. Check the documentation because I have no experience with Rhytmic API.
The best way to address cache performance is to have continuous layout of data in the memory instead of pointers to objects scattered all over main memory. Other than that there is little you can do to affect processor heuristic in prefetching data.
Keep in mind that compiler will pad structs if necessary to align fields and the sizeof can be different than calculated by hand (compiler options how to pad structs are often available). Your solution creates unnecessary large struct.
Check if search is even necessary. Many API assign index to your request or have other specific integer ID attached to returned contract data and you may use it to directly index to your struct using just that. Check the documentation because I have no experience with Rhytmic API.
The best way to address cache performance is to have continuous layout of data in the memory instead of pointers to objects scattered all over main memory. Other than that there is little you can do to affect processor heuristic in prefetching data.
Keep in mind that compiler will pad structs if necessary to align fields and the sizeof can be different than calculated by hand (compiler options how to pad structs are often available). Your solution creates unnecessary large struct.
