- all other juce routines using signed integers
- signed types are better for any kind of offset calculation, with results below 0
I can only speculate, but all containers use
unsigned int as indices, so might be a performance decision(?)
and by using
unsigned int you cannot accidentally read before a buffer (had to find that out the hard way).
But if you overflow value range, it is a disaster anyway…
But yes, your second argument struck me also quite often…
and also these kind of of jasserts will not fire if its overflown
jassert (startSample < numSamples);
FWIW, Stroustrup & Sutter on the topic convinced me here, e.g. https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#es107-dont-use-unsigned-for-subscripts
so probably, the signed variant of size_t, ssize_t is the better choice
There are performance reasons to avoid unsigned as well.
Yes, I agree that the types should probably have been signed, we may replace them at some point.