Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 326672

Summary: org.eclipse.swt.graphics.TextStyle.hashCode() contains "hash ^= hash;"
Product: [Eclipse Project] Platform Reporter: Radu Vlasov <vlasov.r>
Component: SWTAssignee: Felipe Heidrich <eclipse.felipe>
Status: RESOLVED FIXED QA Contact:
Severity: minor    
Priority: P3 CC: eclipse.felipe, remy.suen, Silenio_Quarti
Version: 4.1   
Target Milestone: 3.7 M3   
Hardware: All   
OS: All   
Whiteboard:

Description Radu Vlasov CLA 2010-09-30 10:17:37 EDT
Build Identifier: M20090917-0800

TextStyle.hashCode() contains, among other lines, the following:
   if (underline) hash ^= hash;
   if (strikeout) hash ^= hash;
which would set hash = 0

This may have been done on purpose

Reproducible: Always

Steps to Reproduce:
invoke TextStyle.hashCode() for a StyleRange that has field 'underline' set
Comment 1 Felipe Heidrich CLA 2010-10-13 14:28:51 EDT
That doesn't look good.

Silenio, 
is something like this better:
if (underline) hash ^= (hash << 1);
if (strikeout) hash ^= (hash << 2);
?
Comment 2 Felipe Heidrich CLA 2010-10-13 17:05:17 EDT
Fixed in HEAD > 20101013

Thank you Radu for point this out.