Q: When is optimization sub-optimal? A: When it creates an Android bug that crashes your phone during a call to 911. Details of the bug can be found in Ars Technica , but I want to focus on the integer overflow/underflow that caused the crash: return account1.hashCode() - account2.hashCode(); Nevermind the variable names and the invocation of hashCode() . The problem is subtracting without looking, and returning a number that might be too large or too negative for the program to handle. Google corrected the code by using the Java compare() method: return Integer.compare(account1.hashCode(), account2.hashCode()); which limits the return values to -1, 0, or 1, indicating account1 is less than, equal to, or greater than account2, respectively. This raises two questions: "Why did the original code use subtraction?" and "Wasn't this tested?" Addressing the first question, I've seen overflows and underflows before, and even wrote about them in Space, Time, and I
Comments
I just had a thought. Would it work for you if I would (try to) collapse the grafitti area each time you rotate?