I noticed, that the cloth simulation does not display the number of baked frames correctly when the start frame is negative even though Blender allows me to do this. As the line
* - cfra: frame for the cache, can be negative
is in the code i thought, that this is a bug and tried to solved it. This involed mainly magic number removal.
The part with
if (pid->cache->cached_frames) return pid->cache->cached_frames[cfra - pid->cache->startframe];
comes with quite a speed up for longer simulations, as otherwise Blender tries to read all cache files at every simulated frame, which on my system requires most of the baking time for aid simulations.
I consulted the page https://wiki.blender.org/wiki/Process/Module_Owners/List as to whom to give this for review but it doesn't list someone for "Physics / Other", which is where I would place this patch. Seeing that it might benefit the Rigid Body Simulation as well, I added Sergej Reich.
EDIT: .. and going by the recent commits I was wrong.
From a coding point of view, I tried to follow what I saw in the file, but as I am not that experienced in the C language I could have missed a guildeline or language feature.