Skip to content

Commit f2911f6

Browse files
authored
[Java] Change LinkedList<Diff> to List<Diff> for methods that do not mutate the list.
Copying cr/103024338
1 parent 032b98c commit f2911f6

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

java/src/name/fraser/neil/plaintext/diff_match_patch.java

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -569,10 +569,10 @@ private String diff_linesToCharsMunge(String text, List<String> lineArray,
569569
/**
570570
* Rehydrate the text in a diff from a string of line hashes to real lines of
571571
* text.
572-
* @param diffs LinkedList of Diff objects.
572+
* @param diffs List of Diff objects.
573573
* @param lineArray List of unique strings.
574574
*/
575-
protected void diff_charsToLines(LinkedList<Diff> diffs,
575+
protected void diff_charsToLines(List<Diff> diffs,
576576
List<String> lineArray) {
577577
StringBuilder text;
578578
for (Diff diff : diffs) {
@@ -1304,11 +1304,11 @@ public void diff_cleanupMerge(LinkedList<Diff> diffs) {
13041304
* loc is a location in text1, compute and return the equivalent location in
13051305
* text2.
13061306
* e.g. "The cat" vs "The big cat", 1->1, 5->8
1307-
* @param diffs LinkedList of Diff objects.
1307+
* @param diffs List of Diff objects.
13081308
* @param loc Location within text1.
13091309
* @return Location within text2.
13101310
*/
1311-
public int diff_xIndex(LinkedList<Diff> diffs, int loc) {
1311+
public int diff_xIndex(List<Diff> diffs, int loc) {
13121312
int chars1 = 0;
13131313
int chars2 = 0;
13141314
int last_chars1 = 0;
@@ -1341,10 +1341,10 @@ public int diff_xIndex(LinkedList<Diff> diffs, int loc) {
13411341

13421342
/**
13431343
* Convert a Diff list into a pretty HTML report.
1344-
* @param diffs LinkedList of Diff objects.
1344+
* @param diffs List of Diff objects.
13451345
* @return HTML representation.
13461346
*/
1347-
public String diff_prettyHtml(LinkedList<Diff> diffs) {
1347+
public String diff_prettyHtml(List<Diff> diffs) {
13481348
StringBuilder html = new StringBuilder();
13491349
for (Diff aDiff : diffs) {
13501350
String text = aDiff.text.replace("&", "&amp;").replace("<", "&lt;")
@@ -1368,10 +1368,10 @@ public String diff_prettyHtml(LinkedList<Diff> diffs) {
13681368

13691369
/**
13701370
* Compute and return the source text (all equalities and deletions).
1371-
* @param diffs LinkedList of Diff objects.
1371+
* @param diffs List of Diff objects.
13721372
* @return Source text.
13731373
*/
1374-
public String diff_text1(LinkedList<Diff> diffs) {
1374+
public String diff_text1(List<Diff> diffs) {
13751375
StringBuilder text = new StringBuilder();
13761376
for (Diff aDiff : diffs) {
13771377
if (aDiff.operation != Operation.INSERT) {
@@ -1383,10 +1383,10 @@ public String diff_text1(LinkedList<Diff> diffs) {
13831383

13841384
/**
13851385
* Compute and return the destination text (all equalities and insertions).
1386-
* @param diffs LinkedList of Diff objects.
1386+
* @param diffs List of Diff objects.
13871387
* @return Destination text.
13881388
*/
1389-
public String diff_text2(LinkedList<Diff> diffs) {
1389+
public String diff_text2(List<Diff> diffs) {
13901390
StringBuilder text = new StringBuilder();
13911391
for (Diff aDiff : diffs) {
13921392
if (aDiff.operation != Operation.DELETE) {
@@ -1399,10 +1399,10 @@ public String diff_text2(LinkedList<Diff> diffs) {
13991399
/**
14001400
* Compute the Levenshtein distance; the number of inserted, deleted or
14011401
* substituted characters.
1402-
* @param diffs LinkedList of Diff objects.
1402+
* @param diffs List of Diff objects.
14031403
* @return Number of changes.
14041404
*/
1405-
public int diff_levenshtein(LinkedList<Diff> diffs) {
1405+
public int diff_levenshtein(List<Diff> diffs) {
14061406
int levenshtein = 0;
14071407
int insertions = 0;
14081408
int deletions = 0;
@@ -1431,10 +1431,10 @@ public int diff_levenshtein(LinkedList<Diff> diffs) {
14311431
* required to transform text1 into text2.
14321432
* E.g. =3\t-2\t+ing -> Keep 3 chars, delete 2 chars, insert 'ing'.
14331433
* Operations are tab-separated. Inserted text is escaped using %xx notation.
1434-
* @param diffs Array of Diff objects.
1434+
* @param diffs List of Diff objects.
14351435
* @return Delta text.
14361436
*/
1437-
public String diff_toDelta(LinkedList<Diff> diffs) {
1437+
public String diff_toDelta(List<Diff> diffs) {
14381438
StringBuilder text = new StringBuilder();
14391439
for (Diff aDiff : diffs) {
14401440
switch (aDiff.operation) {

0 commit comments

Comments
 (0)