Or at least CONFIRM that libraries you use are thread safe if you're doing threaded development!
I was recently looking through the source of a 3rd party library I use to see how they did a certain calculation. Hmmm - what are these static variables here for???
Turns out they stored the results in static variables so that they could be returned immediately if the function was called again with the same inputs! It's a fairly expensive set of calculations, and it's pretty likely that it could be called multiple times with the same input, so maybe not a bad idea if you're single threaded.
But it would have really bit me in the ass in my threaded program and been nearly impossible to track down. It would have been one of those bugs that claimed what's left of my hair
Having the source also let me modify the library to take long doubles for a parameter that previously only took doubles and was leading to some unacceptable precision errors.
I was recently looking through the source of a 3rd party library I use to see how they did a certain calculation. Hmmm - what are these static variables here for???
Turns out they stored the results in static variables so that they could be returned immediately if the function was called again with the same inputs! It's a fairly expensive set of calculations, and it's pretty likely that it could be called multiple times with the same input, so maybe not a bad idea if you're single threaded.
But it would have really bit me in the ass in my threaded program and been nearly impossible to track down. It would have been one of those bugs that claimed what's left of my hair
Having the source also let me modify the library to take long doubles for a parameter that previously only took doubles and was leading to some unacceptable precision errors.