Code view:

A painting is a person's account of this edit as text, recorded independently of the node mapping - a rendering often has several equally defensible answers where the mapping has one. Deletions and insertions carry no position on the opposite side in a painting, so that panel draws no caret for them.

Before

…lines 1–420 unchanged (420 lines)
421 * some more duplicates.
422 */
423 private static String cacheString(final char[] charBuf, final String[] stringCache, final int start, final int count) {
424 // limit (no cache):
425 if (count > maxStringCacheLen)
426 return new String(charBuf, start, count);
427
428 // calculate hash:
429 int hash = 0;
430 int offset = start;
431 for (int i = 0; i < count; i++) {
432 hash = 31 * hash + charBuf[offset++];
433 }
…lines 434–474 unchanged (41 lines)

After

…lines 1–420 unchanged (420 lines)
421 * some more duplicates.
422 */
423 private static String cacheString(final char[] charBuf, final String[] stringCache, final int start, final int count) {
424 // limit (no cache):
425 if (count > maxStringCacheLen)
426 return new String(charBuf, start, count);
427 if (count < 1)
428 return "";
429
430 // calculate hash:
431 int hash = 0;
432 int offset = start;
433 for (int i = 0; i < count; i++) {
434 hash = 31 * hash + charBuf[offset++];
…lines 435–476 unchanged (42 lines)

Before

program
package_declaration
package "package"
scoped_identifier
scoped_identifier
identifier "org"
. "."
identifier "jsoup"
. "."
identifier "parser"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
identifier "org"
. "."
identifier "jsoup"
. "."
identifier "UncheckedIOException"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
scoped_identifier
identifier "org"
. "."
identifier "jsoup"
. "."
identifier "helper"
. "."
identifier "Validate"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
identifier "java"
. "."
identifier "io"
. "."
identifier "IOException"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
identifier "java"
. "."
identifier "io"
. "."
identifier "Reader"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
identifier "java"
. "."
identifier "io"
. "."
identifier "StringReader"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
identifier "java"
. "."
identifier "util"
. "."
identifier "Arrays"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
identifier "java"
. "."
identifier "util"
. "."
identifier "Locale"
; ";"
block_comment "/**\n CharacterReader consumes tokens off a string. Used inte"...
class_declaration
modifiers
public "public"
final "final"
class "class"
identifier "CharacterReader"
class_body
{ "{"
field_declaration
modifiers
static "static"
final "final"
integral_type
char "char"
variable_declarator
identifier "EOF"
= "="
cast_expression
( "("
integral_type
char "char"
) ")"
unary_expression
- "-"
decimal_integer_literal "1"
; ";"
field_declaration
modifiers
private "private"
static "static"
final "final"
integral_type
int "int"
variable_declarator
identifier "maxStringCacheLen"
= "="
decimal_integer_literal "12"
; ";"
field_declaration
modifiers
static "static"
final "final"
integral_type
int "int"
variable_declarator
identifier "maxBufferLen"
= "="
binary_expression
decimal_integer_literal "1024"
* "*"
decimal_integer_literal "32"
; ";"
line_comment "// visible for testing"
field_declaration (+23 nodes collapsed)
field_declaration
modifiers
private "private"
final "final"
array_type
integral_type
char "char"
dimensions
[ "["
] "]"
variable_declarator
identifier "charBuf"
; ";"
field_declaration
modifiers
private "private"
final "final"
type_identifier "Reader"
variable_declarator
identifier "reader"
; ";"
field_declaration
modifiers
private "private"
integral_type
int "int"
variable_declarator
identifier "bufLength"
; ";"
field_declaration
modifiers
private "private"
integral_type
int "int"
variable_declarator
identifier "bufSplitPoint"
; ";"
field_declaration
modifiers
private "private"
integral_type
int "int"
variable_declarator
identifier "bufPos"
; ";"
field_declaration
modifiers
private "private"
integral_type
int "int"
variable_declarator
identifier "readerPos"
; ";"
field_declaration
modifiers
private "private"
integral_type
int "int"
variable_declarator
identifier "bufMark"
; ";"
field_declaration
modifiers
private "private"
final "final"
array_type
type_identifier "String"
dimensions
[ "["
] "]"
variable_declarator
identifier "stringCache"
= "="
array_creation_expression
new "new"
type_identifier "String"
dimensions_expr
[ "["
decimal_integer_literal "512"
] "]"
; ";"
line_comment "// holds reused strings in this doc, to lessen garbage"
constructor_declaration (+78 nodes collapsed)
constructor_declaration (+22 nodes collapsed)
constructor_declaration (+34 nodes collapsed)
method_declaration (+123 nodes collapsed)
block_comment "/**\n * Gets the current cursor position in the content.\n"...
method_declaration
modifiers
public "public"
integral_type
int "int"
identifier "pos"
formal_parameters
( "("
) ")"
block
{ "{"
return_statement
return "return"
binary_expression
identifier "readerPos"
+ "+"
identifier "bufPos"
; ";"
} "}"
block_comment "/**\n * Tests if all the content has been read.\n * @r"...
method_declaration
modifiers
public "public"
boolean_type "boolean"
identifier "isEmpty"
formal_parameters
( "("
) ")"
block
{ "{"
return_statement
return "return"
binary_expression
identifier "bufPos"
>= ">="
identifier "bufLength"
; ";"
} "}"
block_comment "/**\n * Get the char at the current position.\n * @ret"...
method_declaration (+36 nodes collapsed)
method_declaration (+47 nodes collapsed)
method_declaration
void_type "void"
identifier "unconsume"
formal_parameters
( "("
) ")"
block
{ "{"
expression_statement
update_expression
identifier "bufPos"
-- "--"
; ";"
} "}"
block_comment "/**\n * Moves the current position by one.\n */"
method_declaration
modifiers
public "public"
void_type "void"
identifier "advance"
formal_parameters
( "("
) ")"
block
{ "{"
expression_statement
update_expression
identifier "bufPos"
++ "++"
; ";"
} "}"
method_declaration
void_type "void"
identifier "mark"
formal_parameters
( "("
) ")"
block
{ "{"
expression_statement
assignment_expression
identifier "bufMark"
= "="
identifier "bufPos"
; ";"
} "}"
method_declaration
void_type "void"
identifier "rewindToMark"
formal_parameters
( "("
) ")"
block
{ "{"
expression_statement
assignment_expression
identifier "bufPos"
= "="
identifier "bufMark"
; ";"
} "}"
block_comment "/**\n * Returns the number of characters between the curr"...
method_declaration (+71 nodes collapsed)
block_comment "/**\n * Returns the number of characters between the curr"...
method_declaration (+215 nodes collapsed)
block_comment "/**\n * Reads characters up to the specific char.\n * "...
method_declaration (+82 nodes collapsed)
method_declaration (+79 nodes collapsed)
block_comment "/**\n * Read characters until the first of any delimiters"...
method_declaration (+137 nodes collapsed)
method_declaration (+128 nodes collapsed)
method_declaration (+137 nodes collapsed)
method_declaration (+167 nodes collapsed)
method_declaration (+47 nodes collapsed)
method_declaration (+118 nodes collapsed)
method_declaration (+169 nodes collapsed)
method_declaration (+123 nodes collapsed)
method_declaration (+90 nodes collapsed)
method_declaration (+33 nodes collapsed)
method_declaration (+100 nodes collapsed)
method_declaration (+133 nodes collapsed)
method_declaration (+77 nodes collapsed)
method_declaration (+53 nodes collapsed)
method_declaration (+76 nodes collapsed)
method_declaration (+51 nodes collapsed)
method_declaration (+57 nodes collapsed)
method_declaration (+50 nodes collapsed)
method_declaration (+80 nodes collapsed)
method_declaration (+31 nodes collapsed)
block_comment "/**\n * Caches short strings, as a flywheel pattern, to r"...
method_declaration
modifiers
private "private"
static "static"
type_identifier "String"
identifier "cacheString"
formal_parameters (+37 nodes collapsed)
block
{ "{"
line_comment "// limit (no cache):"
if_statement (+23 nodes collapsed)
line_comment "// calculate hash:"
local_variable_declaration
integral_type
int "int"
variable_declarator
identifier "hash"
= "="
decimal_integer_literal "0"
; ";"
local_variable_declaration
integral_type
int "int"
variable_declarator
identifier "offset"
= "="
identifier "start"
; ";"
for_statement (+41 nodes collapsed)
line_comment "// get from cache"
local_variable_declaration
modifiers
final "final"
integral_type
int "int"
variable_declarator
identifier "index"
= "="
binary_expression
identifier "hash"
& "&"
binary_expression
field_access
identifier "stringCache"
. "."
identifier "length"
- "-"
decimal_integer_literal "1"
; ";"
local_variable_declaration
type_identifier "String"
variable_declarator
identifier "cached"
= "="
array_access
identifier "stringCache"
[ "["
identifier "index"
] "]"
; ";"
if_statement (+101 nodes collapsed)
return_statement
return "return"
identifier "cached"
; ";"
} "}"
block_comment "/**\n * Check if the value of the provided range equals t"...
method_declaration (+123 nodes collapsed)
line_comment "// just used for testing"
method_declaration (+43 nodes collapsed)
} "}"

After

program
package_declaration
package "package"
scoped_identifier
scoped_identifier
identifier "org"
. "."
identifier "jsoup"
. "."
identifier "parser"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
identifier "org"
. "."
identifier "jsoup"
. "."
identifier "UncheckedIOException"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
scoped_identifier
identifier "org"
. "."
identifier "jsoup"
. "."
identifier "helper"
. "."
identifier "Validate"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
identifier "java"
. "."
identifier "io"
. "."
identifier "IOException"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
identifier "java"
. "."
identifier "io"
. "."
identifier "Reader"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
identifier "java"
. "."
identifier "io"
. "."
identifier "StringReader"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
identifier "java"
. "."
identifier "util"
. "."
identifier "Arrays"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
identifier "java"
. "."
identifier "util"
. "."
identifier "Locale"
; ";"
block_comment "/**\n CharacterReader consumes tokens off a string. Used inte"...
class_declaration
modifiers
public "public"
final "final"
class "class"
identifier "CharacterReader"
class_body
{ "{"
field_declaration
modifiers
static "static"
final "final"
integral_type
char "char"
variable_declarator
identifier "EOF"
= "="
cast_expression
( "("
integral_type
char "char"
) ")"
unary_expression
- "-"
decimal_integer_literal "1"
; ";"
field_declaration
modifiers
private "private"
static "static"
final "final"
integral_type
int "int"
variable_declarator
identifier "maxStringCacheLen"
= "="
decimal_integer_literal "12"
; ";"
field_declaration
modifiers
static "static"
final "final"
integral_type
int "int"
variable_declarator
identifier "maxBufferLen"
= "="
binary_expression
decimal_integer_literal "1024"
* "*"
decimal_integer_literal "32"
; ";"
line_comment "// visible for testing"
field_declaration (+23 nodes collapsed)
field_declaration
modifiers
private "private"
final "final"
array_type
integral_type
char "char"
dimensions
[ "["
] "]"
variable_declarator
identifier "charBuf"
; ";"
field_declaration
modifiers
private "private"
final "final"
type_identifier "Reader"
variable_declarator
identifier "reader"
; ";"
field_declaration
modifiers
private "private"
integral_type
int "int"
variable_declarator
identifier "bufLength"
; ";"
field_declaration
modifiers
private "private"
integral_type
int "int"
variable_declarator
identifier "bufSplitPoint"
; ";"
field_declaration
modifiers
private "private"
integral_type
int "int"
variable_declarator
identifier "bufPos"
; ";"
field_declaration
modifiers
private "private"
integral_type
int "int"
variable_declarator
identifier "readerPos"
; ";"
field_declaration
modifiers
private "private"
integral_type
int "int"
variable_declarator
identifier "bufMark"
; ";"
field_declaration
modifiers
private "private"
final "final"
array_type
type_identifier "String"
dimensions
[ "["
] "]"
variable_declarator
identifier "stringCache"
= "="
array_creation_expression
new "new"
type_identifier "String"
dimensions_expr
[ "["
decimal_integer_literal "512"
] "]"
; ";"
line_comment "// holds reused strings in this doc, to lessen garbage"
constructor_declaration (+78 nodes collapsed)
constructor_declaration (+22 nodes collapsed)
constructor_declaration (+34 nodes collapsed)
method_declaration (+123 nodes collapsed)
block_comment "/**\n * Gets the current cursor position in the content.\n"...
method_declaration
modifiers
public "public"
integral_type
int "int"
identifier "pos"
formal_parameters
( "("
) ")"
block
{ "{"
return_statement
return "return"
binary_expression
identifier "readerPos"
+ "+"
identifier "bufPos"
; ";"
} "}"
block_comment "/**\n * Tests if all the content has been read.\n * @r"...
method_declaration
modifiers
public "public"
boolean_type "boolean"
identifier "isEmpty"
formal_parameters
( "("
) ")"
block
{ "{"
return_statement
return "return"
binary_expression
identifier "bufPos"
>= ">="
identifier "bufLength"
; ";"
} "}"
block_comment "/**\n * Get the char at the current position.\n * @ret"...
method_declaration (+36 nodes collapsed)
method_declaration (+47 nodes collapsed)
method_declaration
void_type "void"
identifier "unconsume"
formal_parameters
( "("
) ")"
block
{ "{"
expression_statement
update_expression
identifier "bufPos"
-- "--"
; ";"
} "}"
block_comment "/**\n * Moves the current position by one.\n */"
method_declaration
modifiers
public "public"
void_type "void"
identifier "advance"
formal_parameters
( "("
) ")"
block
{ "{"
expression_statement
update_expression
identifier "bufPos"
++ "++"
; ";"
} "}"
method_declaration
void_type "void"
identifier "mark"
formal_parameters
( "("
) ")"
block
{ "{"
expression_statement
assignment_expression
identifier "bufMark"
= "="
identifier "bufPos"
; ";"
} "}"
method_declaration
void_type "void"
identifier "rewindToMark"
formal_parameters
( "("
) ")"
block
{ "{"
expression_statement
assignment_expression
identifier "bufPos"
= "="
identifier "bufMark"
; ";"
} "}"
block_comment "/**\n * Returns the number of characters between the curr"...
method_declaration (+71 nodes collapsed)
block_comment "/**\n * Returns the number of characters between the curr"...
method_declaration (+215 nodes collapsed)
block_comment "/**\n * Reads characters up to the specific char.\n * "...
method_declaration (+82 nodes collapsed)
method_declaration (+79 nodes collapsed)
block_comment "/**\n * Read characters until the first of any delimiters"...
method_declaration (+137 nodes collapsed)
method_declaration (+128 nodes collapsed)
method_declaration (+137 nodes collapsed)
method_declaration (+167 nodes collapsed)
method_declaration (+47 nodes collapsed)
method_declaration (+118 nodes collapsed)
method_declaration (+169 nodes collapsed)
method_declaration (+123 nodes collapsed)
method_declaration (+90 nodes collapsed)
method_declaration (+33 nodes collapsed)
method_declaration (+100 nodes collapsed)
method_declaration (+133 nodes collapsed)
method_declaration (+77 nodes collapsed)
method_declaration (+53 nodes collapsed)
method_declaration (+76 nodes collapsed)
method_declaration (+51 nodes collapsed)
method_declaration (+57 nodes collapsed)
method_declaration (+50 nodes collapsed)
method_declaration (+80 nodes collapsed)
method_declaration (+31 nodes collapsed)
block_comment "/**\n * Caches short strings, as a flywheel pattern, to r"...
method_declaration
modifiers
private "private"
static "static"
type_identifier "String"
identifier "cacheString"
formal_parameters (+37 nodes collapsed)
block
{ "{"
line_comment "// limit (no cache):"
if_statement (+23 nodes collapsed)
if_statement
if "if"
parenthesized_expression
( "("
binary_expression
identifier "count"
< "<"
decimal_integer_literal "1"
) ")"
return_statement
return "return"
string_literal
" "\""
" "\""
; ";"
line_comment "// calculate hash:"
local_variable_declaration
integral_type
int "int"
variable_declarator
identifier "hash"
= "="
decimal_integer_literal "0"
; ";"
local_variable_declaration
integral_type
int "int"
variable_declarator
identifier "offset"
= "="
identifier "start"
; ";"
for_statement (+41 nodes collapsed)
line_comment "// get from cache"
local_variable_declaration
modifiers
final "final"
integral_type
int "int"
variable_declarator
identifier "index"
= "="
binary_expression
identifier "hash"
& "&"
binary_expression
field_access
identifier "stringCache"
. "."
identifier "length"
- "-"
decimal_integer_literal "1"
; ";"
local_variable_declaration
type_identifier "String"
variable_declarator
identifier "cached"
= "="
array_access
identifier "stringCache"
[ "["
identifier "index"
] "]"
; ";"
if_statement (+101 nodes collapsed)
return_statement
return "return"
identifier "cached"
; ";"
} "}"
block_comment "/**\n * Check if the value of the provided range equals t"...
method_declaration (+123 nodes collapsed)
line_comment "// just used for testing"
method_declaration (+43 nodes collapsed)
} "}"