Skip to content

Commit d8dba12

Browse files
Code optimisation
1 parent 94c61ca commit d8dba12

File tree

3 files changed

+20
-38
lines changed

3 files changed

+20
-38
lines changed

org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/AbstractCommentParser.java

Lines changed: 18 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1394,47 +1394,29 @@ protected boolean parseReference() throws InvalidInputException {
13941394
}
13951395

13961396
// Parses a complete URL reference starting from current position
1397-
protected boolean parseURLReference() throws InvalidInputException {
1398-
int pos = 0;
1397+
protected boolean parseURLReference(int pos, boolean advanceEndPos) throws InvalidInputException {
13991398
char[]fullURL = null;
14001399
int firstTokenStartPos;
14011400
StringBuilder urlBuilder = new StringBuilder();
14021401
char c;
1403-
if (this.source[this.index] == '(') {
1404-
firstTokenStartPos = this.index;
1405-
while (pos < this.source.length) {
1406-
c = readChar();
1407-
if (c == '[') // invalid syntax for url
1408-
return false;
1409-
if (c == '(' || c == ' ')
1410-
continue;
1411-
1412-
if (c == '\n' || c == '\r' || c == ')' ) {
1413-
break;
1414-
}
1415-
urlBuilder.append(c);
1416-
}
1417-
pos = this.index - 1;
1418-
fullURL = urlBuilder.toString().toCharArray();
1419-
} else {
1420-
pos = this.scanner.startPosition - 1;
1421-
firstTokenStartPos = pos;
1422-
while (pos < this.source.length) {
1423-
c = this.source[pos];
1424-
if (c == '[') // invalid syntax for url
1425-
return false;
1426-
if (c == '(' || c == ' ') {
1427-
pos++;
1428-
continue;
1429-
}
1430-
if (c == '\n' || c == '\r' || c == ')') {
1431-
break;
1432-
}
1433-
urlBuilder.append(c);
1434-
pos++;
1402+
firstTokenStartPos = pos;
1403+
while (pos < this.source.length) {
1404+
c = this.source[pos];
1405+
if (c == '[') // invalid syntax for url
1406+
return false;
1407+
if (c == '(' || c == ' ') {
1408+
pos++;
1409+
continue;
14351410
}
1436-
fullURL = urlBuilder.toString().toCharArray();
1437-
}
1411+
if (c == '\n' || c == '\r' || c == ')') {
1412+
break;
1413+
}
1414+
urlBuilder.append(c);
1415+
pos++;
1416+
}
1417+
if (advanceEndPos)
1418+
this.index = pos;
1419+
fullURL = urlBuilder.toString().toCharArray();
14381420

14391421
this.identifierPtr = 0;
14401422
this.identifierStack[this.identifierPtr] = fullURL;

org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/JavadocParser.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -582,7 +582,7 @@ protected boolean parseMarkdownLinks(int previousPosition) throws InvalidInputEx
582582
currentChar = readChar();
583583
start = this.index;
584584
} else if (peekChar() == '(') {
585-
valid = parseURLReference();
585+
valid = parseURLReference(this.index, true);
586586
} else {
587587
break loop;
588588
}

org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/DocCommentParser.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -772,7 +772,7 @@ private boolean parseMarkdownLinkTags(boolean refFlag, int start, int previousPo
772772
this.tagValue = TAG_LINK_VALUE;
773773
int indexBkup = this.index;
774774
if (refFlag)
775-
valid = parseURLReference();
775+
valid = parseURLReference(this.scanner.startPosition - 1, false);
776776
else
777777
valid = parseReference(true);
778778
this.index = indexBkup;

0 commit comments

Comments
 (0)