According to the sources here (which is just one implementation, others may act differently), compare
doesn't check the length first, which actually makes sense since it's not an equality check. As it returns a less-than/equal-to/greater-than return code, it has to check the characters, even if the lengths are the same.
A pure isEqual
-type method may be able to shortcut character checks if the lengths are different, but compare
does not have that luxury.
It does do certain checks of the length against zero, but not comparisons of the two lengths against each other.