if (index == 0) { return cached; } else if (index >= end) { return OUT_OF_BOUNDS; } else if (index >= bufsize) { // Allocate more space in the buffer. try { while (bufsize <= index) bufsize += BUFFER_INCREMENT; br.reset(); br.mark(bufsize); br.skip(index-1); } catch (IOException e) { } } else if (this.index != index) { try { br.reset(); br.skip(index-1); } catch (IOException e) { } } else if (index == -1) { return lookBehind[0]; } else if (index == -2) { return lookBehind[1]; } else if (index < -2) { return OUT_OF_BOUNDS; } char ch = OUT_OF_BOUNDS; try { int i = br.read(); this.index = index+1; // this.index is index of next pos relative to charAt(0) if (i == -1) { // set flag that next should fail next time? end = index; return ch; } ch = (char) i; } catch (IOException ie) { } return ch;
if (index == 0) { return cached; } else if (index >= end) { return OUT_OF_BOUNDS; } else if (index == -1) { return lookBehind[0]; } else if (index == -2) { return lookBehind[1]; } else if (index < -2) { return OUT_OF_BOUNDS; } else if (index >= bufsize) { // Allocate more space in the buffer. try { while (bufsize <= index) bufsize += BUFFER_INCREMENT; br.reset(); br.mark(bufsize); br.skip(index-1); } catch (IOException e) { } } else if (this.index != index) { try { br.reset(); br.skip(index-1); } catch (IOException e) { } } char ch = OUT_OF_BOUNDS; try { int i = br.read(); this.index = index+1; // this.index is index of next pos relative to charAt(0) if (i == -1) { // set flag that next should fail next time? end = index; return ch; } ch = (char) i; } catch (IOException ie) { } return ch;
Clone fragments detected by clone detection tool
File path: /jEdit-4.2/src/gnu/regexp/CharIndexedReader.java File path: /jEdit-4.2/src/gnu/regexp/CharIndexedInputStream.java
Method name: char charAt(int) Method name: char charAt(int)
Number of AST nodes: 30 Number of AST nodes: 30
1
if (index == 0) {
1
if (index == 0) {
2
	    return cached;
2
	    return cached;
3
	} else if (index >= end) {
3
	} else if (index >= end) {
4
	    return OUT_OF_BOUNDS;
4
	    return OUT_OF_BOUNDS;
5
	
5
	} else if (index == -1) {
6
	    return lookBehind[0];
7
	} else if (index == -2) {
8
	    return lookBehind[1];
9
	} else if (index < -2) {
10
	    return OUT_OF_BOUNDS;
6
} else if (index >= bufsize) {
11
	} else if (index >= bufsize) {
7
	    // Allocate more space in the buffer.
12
	    // Allocate more space in the buffer.
8
	    try {
13
	    try {
9
		while (bufsize <= index) bufsize += BUFFER_INCREMENT;
14
		while (bufsize <= index) bufsize += BUFFER_INCREMENT;
10
		br.reset();
15
		br.reset();
11
		br.mark(bufsize);
16
		br.mark(bufsize);
12
		br.skip(index-1);
17
		br.skip(index-1);
13
	    } catch (IOException e) { }
18
	    } catch (IOException e) { }
14
	} else if (this.index != index) {
19
	} else if (this.index != index) {
15
	    try {
20
	    try {
16
		br.reset();
21
		br.reset();
17
		br.skip(index-1);
22
		br.skip(index-1);
18
	    } catch (IOException e) { }
23
	    } catch (IOException e) { }
19
	} else if (index == -1) {
24
	}
20
	    return lookBehind[0];
21
	} else if (index == -2) {
22
	    return lookBehind[1];
23
	} else if (index < -2) {
24
	    return OUT_OF_BOUNDS;
25
	}
26
	char ch = OUT_OF_BOUNDS;
25
	char ch = OUT_OF_BOUNDS;
27
	
26
	
28
	try {
27
	try {
29
	    int i = br.read();
28
	    int i = br.read();
30
	    this.index = index+1; // this.index is index of next pos relative to charAt(0)
29
	    this.index = index+1; // this.index is index of next pos relative to charAt(0)
31
	    if (i == -1) {
30
	    if (i == -1) {
32
		// set flag that next should fail next time?
31
		// set flag that next should fail next time?
33
		end = index;
32
		end = index;
34
		return ch;
33
		return ch;
35
	    }
34
	    }
36
	    ch = (char) i;
35
	    ch = (char) i;
37
	} catch (IOException ie) { }
36
	} catch (IOException ie) { }
38
	
37
	
39
	return ch;
38
	return ch;
Summary
Number of common nesting structure subtrees1
Number of refactorable cases0
Number of non-refactorable cases1
Time elapsed for finding largest common nesting structure subtrees (ms)23.0
Clones locationClones are in different classes
Number of node comparisons179
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements30
    Number of unmapped statements in the first code fragment0
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)28.2
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    1
    if (index == 0)
    1
    if (index == 0)
    2
    return cached;
    2
    return cached;
    3
    else if (index >= end)
    3
    else if (index >= end)
    4
    return OUT_OF_BOUNDS;
    4
    return OUT_OF_BOUNDS;
    5
    else if (index >= bufsize)
    11
    else if (index >= bufsize)
    6
    try
    12
    try
    7
    while (bufsize <= index)
    13
    while (bufsize <= index)
    8
    bufsize += BUFFER_INCREMENT;
    14
    bufsize += BUFFER_INCREMENT;
    9
    br.reset();
    9
    br.reset();
    15
    br.reset();
    Differences
    Expression1Expression2Difference
    java.io.BufferedReaderjava.io.BufferedInputStreamVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type java.io.BufferedReader of variable br does not match with type java.io.BufferedInputStream of variable br
    • Make classes java.io.BufferedReader and java.io.BufferedInputStream extend a common superclass
    15
    br.reset();
    10
    br.mark(bufsize);
    10
    br.mark(bufsize);
    16
    br.mark(bufsize);
    Differences
    Expression1Expression2Difference
    java.io.BufferedReaderjava.io.BufferedInputStreamVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type java.io.BufferedReader of variable br does not match with type java.io.BufferedInputStream of variable br
    • Make classes java.io.BufferedReader and java.io.BufferedInputStream extend a common superclass
    16
    br.mark(bufsize);
    11
    br.skip(index - 1);
    11
    br.skip(index - 1);
    17
    br.skip(index - 1);
    Differences
    Expression1Expression2Difference
    java.io.BufferedReaderjava.io.BufferedInputStreamVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type java.io.BufferedReader of variable br does not match with type java.io.BufferedInputStream of variable br
    • Make classes java.io.BufferedReader and java.io.BufferedInputStream extend a common superclass
    17
    br.skip(index - 1);
    12
    else if (this.index != index)
    18
    else if (this.index != index)
    13
    try
    19
    try
    14
    br.reset();
    14
    br.reset();
    20
    br.reset();
    Differences
    Expression1Expression2Difference
    java.io.BufferedReaderjava.io.BufferedInputStreamVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type java.io.BufferedReader of variable br does not match with type java.io.BufferedInputStream of variable br
    • Make classes java.io.BufferedReader and java.io.BufferedInputStream extend a common superclass
    20
    br.reset();
    15
    br.skip(index - 1);
    15
    br.skip(index - 1);
    21
    br.skip(index - 1);
    Differences
    Expression1Expression2Difference
    java.io.BufferedReaderjava.io.BufferedInputStreamVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type java.io.BufferedReader of variable br does not match with type java.io.BufferedInputStream of variable br
    • Make classes java.io.BufferedReader and java.io.BufferedInputStream extend a common superclass
    21
    br.skip(index - 1);
    16
    else if (index == -1)
    5
    else if (index == -1)
    17
    return lookBehind[0];
    6
    return lookBehind[0];
    18
    else if (index == -2)
    7
    else if (index == -2)
    19
    return lookBehind[1];
    8
    return lookBehind[1];
    20
    else if (index < -2)
    9
    else if (index < -2)
    21
    return OUT_OF_BOUNDS;
    10
    return OUT_OF_BOUNDS;
    22
    char ch = OUT_OF_BOUNDS;
    22
    char ch = OUT_OF_BOUNDS;
    23
    try
    23
    try
    24
    int i = br.read();
    24
    int i = br.read();
    24
    int i = br.read();
    Differences
    Expression1Expression2Difference
    java.io.BufferedReaderjava.io.BufferedInputStreamVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type java.io.BufferedReader of variable br does not match with type java.io.BufferedInputStream of variable br
    • Make classes java.io.BufferedReader and java.io.BufferedInputStream extend a common superclass
    24
    int i = br.read();
    25
    this.index = index + 1;
    25
    this.index = index + 1;
    26
    if (i == -1)
    26
    if (i == -1)
    27
    end = index;
    27
    end = index;
    28
    return ch;
    28
    return ch;
    29
    ch = (char)i;
    29
    ch = (char)i;
    30
    return ch;
    30
    return ch;
    Precondition Violations (6)
    Row Violation
    1Type java.io.BufferedReader of variable br does not match with type java.io.BufferedInputStream of variable br
    2Type java.io.BufferedReader of variable br does not match with type java.io.BufferedInputStream of variable br
    3Type java.io.BufferedReader of variable br does not match with type java.io.BufferedInputStream of variable br
    4Type java.io.BufferedReader of variable br does not match with type java.io.BufferedInputStream of variable br
    5Type java.io.BufferedReader of variable br does not match with type java.io.BufferedInputStream of variable br
    6Type java.io.BufferedReader of variable br does not match with type java.io.BufferedInputStream of variable br