int i;
int ok = 0;
while (len-- > 0) {
i = read();
if (i == -1) return (ok == 0) ? -1 : ok;
b[off++] = (byte) i;
ok++;
}
return ok;
int i;
int ok = 0;
while (len-- > 0) {
i = read();
if (i == -1) return (ok == 0) ? -1 : ok;
b[off++] = (char) i;
ok++;
}
return ok;
Clone fragments detected by clone detection tool
File path: /jEdit-4.2/src/gnu/regexp/REFilterInputStream.java
|
|
File path: /jEdit-4.2/src/gnu/regexp/REFilterReader.java
|
Method name: int read(byte[], int, int)
|
|
Method name: int read(char[], int, int)
|
Number of AST nodes: 9
|
|
Number of AST nodes: 9
|
|
1 | int i;↵ | | 1 | int i;↵
|
2 | int ok = 0;↵ | | 2 | int ok = 0;↵
|
3 | while (len-- > 0) {↵ | | 3 | while (len-- > 0) {↵
|
4 | i = read();↵ | | 4 | i = read();↵
|
5 | if (i == -1) return (ok == 0) ? -1 : ok;↵ | | 5 | if (i == -1) return (ok == 0) ? -1 : ok;↵
|
6 | b[off++] = (byte) i;↵ | | 6 | b[off++] = (char) i;↵
|
7 | ok++;↵ | | 7 | ok++;↵
|
8 | }↵ | | 8 | }↵
|
9 | return ok; | | 9 | return ok;
|
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 in different classes |
Number of node comparisons | 27 |
-
{Non-refactorable}
Mapping Summary
Number of mapped statements | 8 |
Number of unmapped statements in the first code fragment | 1 |
Number of unmapped statements in the second code fragment | 1 |
Time elapsed for statement mapping (ms) | 4.9 |
Clone type | Type 2 |
Mapped Statements
ID |
Statement |
|
ID |
Statement |
1 | int i; | | 1 | int i; |
2 | int ok = 0; | | 2 | int ok = 0; |
3 | while (len-- > 0) | | 3 | while (len-- > 0) |
4 | | | 4 | |
5 | | | 5 | |
6 | return (ok == 0) ? -1 : ok; | | 6 | return (ok == 0) ? -1 : ok; |
| | | 7 | |
7 | | | | |
8 | | | 8 | |
9 | return ok; | | 9 | return ok; |
Precondition Violations (3)
Row |
Violation |
1 | Unmatched statement b[off++]=(char)i; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
2 | Unmatched statement b[off++]=(byte)i; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
3 | The refactoring of the clones is infeasible, because classes gnu.regexp.REFilterInputStream and gnu.regexp.REFilterReader do not have a common superclass |