for ( int indx = 0; indx < stringLength; indx++ ) {
char c = string.charAt( indx );
if ( inQuote ) {
if ( '\'' == c ) {
inQuote = false;
}
}
else if ( '\'' == c ) {
inQuote = true;
}
else if ( c == character ) {
count++;
}
}
for ( int indx = 0; indx < stringLength; indx++ ) {
char c = string.charAt( indx );
if ( inQuote ) {
if ( '\'' == c ) {
inQuote = false;
}
}
else if ( '\'' == c ) {
inQuote = true;
}
else if ( c == character ) {
locations.add( new Integer( indx ) );
}
}
Clone fragments detected by clone detection tool
File path: /hibernate-distribution-3.3.2.GA/project/core/src/main/java/org/hibernate/util/StringHelper.java
|
|
File path: /hibernate-distribution-3.3.2.GA/project/core/src/main/java/org/hibernate/util/StringHelper.java
|
Method name: int countUnquoted(String, char)
|
|
Method name: int[] locateUnquoted(String, char)
|
Number of AST nodes: 9
|
|
Number of AST nodes: 9
|
|
1 | for ( int indx = 0; indx < stringLength; indx++ ) {↵ | | 1 | for ( int indx = 0; indx < stringLength; indx++ ) {↵
|
2 | char c = string.charAt( indx );↵ | | 2 | char c = string.charAt( indx );↵
|
3 | if ( inQuote ) {↵ | | 3 | if ( inQuote ) {↵
|
4 | if ( '\'' == c ) {↵ | | 4 | if ( '\'' == c ) {↵
|
5 | inQuote = false;↵ | | 5 | inQuote = false;↵
|
6 | }↵ | | 6 | }↵
|
7 | }↵ | | 7 | }↵
|
8 | else if ( '\'' == c ) {↵ | | 8 | else if ( '\'' == c ) {↵
|
9 | inQuote = true;↵ | | 9 | inQuote = true;↵
|
10 | }↵ | | 10 | }↵
|
11 | else if ( c == character ) {↵ | | 11 | else if ( c == character ) {↵
|
12 | count++;↵ | | 12 | locations.add( new Integer( indx ) );↵
|
13 | }↵ | | 13 | }↵
|
14 | } | | 14 | }
|
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.6 |
Clones location | Clones are declared in the same class |
Number of node comparisons | 22 |
-
{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) | 1.2 |
Clone type | Type 2 |
Mapped Statements
ID |
Statement |
|
ID |
Statement |
8 | for (int indx = 0; indx < stringLength; indx++) | | 8 | for (int indx = 0; indx < stringLength; indx++) |
9 | char c = string.charAt(indx); | | 9 | char c = string.charAt(indx); |
10 | | | 10 | |
11 | | | 11 | |
12 | | | 12 | |
13 | | | 13 | |
14 | | | 14 | |
15 | | | 15 | |
| | | 16 | locations.add(new Integer(indx)); |
16 | | | | |
Precondition Violations (3)
Row |
Violation |
1 | Unmatched statement locations.add(new Integer(indx)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
2 | Unmatched statement count++; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
3 | Clone fragment #1 returns variables , while Clone fragment #2 returns variables indx |