161-2-3

if (list == null) { return pre; } int result = 127; int size = list.size(); result = HashUtilities.hashCode(result, size); // for efficiency, we just use the first, last and middle items to // compute a hashCode... if (size > 0) { result = HashUtilities.hashCode(result, list.getPaint(0)); if (size > 1) { result = HashUtilities.hashCode(result, list.getPaint(size - 1)); if (size > 2) { result = HashUtilities.hashCode(result, list.getPaint(size / 2)); } } } return 37 * pre + result;
if (list == null) { return pre; } int result = 127; int size = list.size(); result = HashUtilities.hashCode(result, size); // for efficiency, we just use the first, last and middle items to // compute a hashCode... if (size > 0) { result = HashUtilities.hashCode(result, list.getBoolean(0)); if (size > 1) { result = HashUtilities.hashCode(result, list.getBoolean(size - 1)); if (size > 2) { result = HashUtilities.hashCode(result, list.getBoolean(size / 2)); } } } return 37 * pre + result;

Clone fragments detected by clone detection tool
File path: /jfreechart-1.0.10/src/org/jfree/chart/HashUtilities.java |  | File path: /jfreechart-1.0.10/src/org/jfree/chart/HashUtilities.java
Method name: `int hashCode(int, PaintList)` |  | Method name: `int hashCode(int, BooleanList)`
Number of AST nodes: 12 |  | Number of AST nodes: 12

1

    if (list == null) {↵

1

    if (list == null) {↵

2

                return pre;↵

2

                return pre;↵

3

            }↵

3

            }↵

4

            int result = 127;↵

4

            int result = 127;↵

5

            int size = list.size();↵

5

            int size = list.size();↵

6

            result = HashUtilities.hashCode(result, size);↵

6

            result = HashUtilities.hashCode(result, size);↵

7

            ↵

7

            ↵

8

            // for efficiency, we just use the first, last and middle items to↵

8

            // for efficiency, we just use the first, last and middle items to↵

9

            // compute a hashCode...↵

9

            // compute a hashCode...↵

10

            if (size > 0) {↵

10

            if (size > 0) {↵

11

                result = HashUtilities.hashCode(result, list.getPaint(0));↵

11

                result = HashUtilities.hashCode(result, list.getBoolean(0));↵

12

                if (size > 1) {↵

12

                if (size > 1) {↵

13

                    result = HashUtilities.hashCode(result, ↵

13

                    result = HashUtilities.hashCode(result, ↵

14

                            list.getPaint(size - 1));↵

14

                            list.getBoolean(size - 1));↵

15

                    if (size > 2) {↵

15

                    if (size > 2) {↵

16

                        result = HashUtilities.hashCode(result, ↵

16

                        result = HashUtilities.hashCode(result, ↵

17

                                list.getPaint(size / 2));↵

17

                                list.getBoolean(size / 2));↵

18

                    }↵

18

                    }↵

19

                }↵

19

                }↵

20

            }↵

20

            }↵

21

            return 37 * pre + result;

21

            return 37 * pre + result;

See real code fragment |  | See real code fragment

Summary
Number of common nesting structure subtrees | 1
Number of refactorable cases | 0
Number of non-refactorable cases | 1
Time elapsed for finding largest common nesting structure subtrees (ms) | 0.2
Clones location | Clones are declared in the same class
Number of node comparisons | 32

1. {Non-refactorable}

   Mapping Summary
   Number of mapped statements | 9
   Number of unmapped statements in the first code fragment | 3
   Number of unmapped statements in the second code fragment | 3
   Time elapsed for statement mapping (ms) | 1.5
   Clone type | Type 2

   Mapped Statements
   ID | Statement |  | ID | Statement
   --- | --- | --- | --- | ---

   1

       if (list == null)

   1 | if (list == null)
   1 | if (list == null)

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   org.jfree.util.PaintList | org.jfree.util.BooleanList | SUBCLASS_TYPE_MISMATCH

   1

       if (list == null)

   2

       return pre;

   2

       return pre;

   3

       int result = 127;

   3

       int result = 127;

   4

       int size = list.size();

   4 | int size = list.size();
   4 | int size = list.size();

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   org.jfree.util.PaintList | org.jfree.util.BooleanList | SUBCLASS_TYPE_MISMATCH

   4

       int size = list.size();

   5

       result = HashUtilities.hashCode(result, size);

   5

       result = HashUtilities.hashCode(result, size);

   6

       if (size > 0)

   6

       if (size > 0)

   7 | result = HashUtilities.hashCode(result, list.getBoolean(0));

   Preondition Violations
   Unmatched statement result=HashUtilities.hashCode(result,list.getBoolean(0)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted

   7

       result = HashUtilities.hashCode(result, list.getBoolean(0));

   7

       result = HashUtilities.hashCode(result, list.getPaint(0));

   7 | result = HashUtilities.hashCode(result, list.getPaint(0));

   Preondition Violations
   Unmatched statement result=HashUtilities.hashCode(result,list.getPaint(0)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted

   8

       if (size > 1)

   8

       if (size > 1)

   9 | result = HashUtilities.hashCode(result, list.getBoolean(size - 1));

   Preondition Violations
   Unmatched statement result=HashUtilities.hashCode(result,list.getBoolean(size - 1)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted

   9

       result = HashUtilities.hashCode(result, list.getBoolean(size - 1));

   9

       result = HashUtilities.hashCode(result, list.getPaint(size - 1));

   9 | result = HashUtilities.hashCode(result, list.getPaint(size - 1));

   Preondition Violations
   Unmatched statement result=HashUtilities.hashCode(result,list.getPaint(size - 1)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted

   10

       if (size > 2)

   10

       if (size > 2)

   11 | result = HashUtilities.hashCode(result, list.getBoolean(size / 2));

   Preondition Violations
   Unmatched statement result=HashUtilities.hashCode(result,list.getBoolean(size / 2)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted

   11

       result = HashUtilities.hashCode(result, list.getBoolean(size / 2));

   11

       result = HashUtilities.hashCode(result, list.getPaint(size / 2));

   11 | result = HashUtilities.hashCode(result, list.getPaint(size / 2));

   Preondition Violations
   Unmatched statement result=HashUtilities.hashCode(result,list.getPaint(size / 2)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted

   12

       return 37 * pre + result;

   12

       return 37 * pre + result;

   Precondition Violations (7)
   Row | Violation
   --- | ---
   1 | Unmatched statement result=HashUtilities.hashCode(result,list.getBoolean(0)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
   2 | Unmatched statement result=HashUtilities.hashCode(result,list.getPaint(0)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
   3 | Unmatched statement result=HashUtilities.hashCode(result,list.getBoolean(size - 1)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
   4 | Unmatched statement result=HashUtilities.hashCode(result,list.getPaint(size - 1)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
   5 | Unmatched statement result=HashUtilities.hashCode(result,list.getBoolean(size / 2)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
   6 | Unmatched statement result=HashUtilities.hashCode(result,list.getPaint(size / 2)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
   7 | Clone fragment #1 returns variables result, size , while Clone fragment #2 returns variables result, size