Skip to content

Commit

Permalink
removing char boxing
Browse files Browse the repository at this point in the history
  • Loading branch information
kzn committed Jan 13, 2011
1 parent aabd34f commit 2dd2968
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/main/java/org/jsoup/parser/Parser.java
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ private Attribute parseAttribute() {
private void parseTextNode() {
TextNode textNode;
// special case: handle string like "hello < there". first char will be "<", because of matchStartTag
if (tq.peek().equals('<')) {
if (tq.peek() =='<') {
tq.advance();
textNode = new TextNode("<", baseUri);
} else {
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/org/jsoup/parser/TokenQueue.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ private int remainingLength() {

/**
* Retrieves but does not remove the first character from the queue.
* @return First character, or null if empty.
* @return First character, or 0 if empty.
*/
public Character peek() {
return isEmpty() ? null : queue.charAt(pos);
public char peek() {
return isEmpty() ? 0 : queue.charAt(pos);
}

/**
Expand Down Expand Up @@ -158,8 +158,8 @@ public void advance() {
* Consume one character off queue.
* @return first character on queue.
*/
public Character consume() {
Character c = queue.charAt(pos);
public char consume() {
char c = queue.charAt(pos);
pos++;
return c;
}
Expand Down
16 changes: 8 additions & 8 deletions src/main/java/org/jsoup/select/Selector.java
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ private Elements select() {

if (tq.matchesAny(combinators)) { // if starts with a combinator, use root as elements
elements.add(root);
combinator(tq.consume().toString());
combinator(tq.consume());
} else if (tq.matches(":has(")) {
elements.addAll(root.getAllElements());
} else {
Expand All @@ -123,9 +123,9 @@ private Elements select() {
elements.addAll(select(subQuery, root));
}
} else if (tq.matchesAny(combinators)) {
combinator(tq.consume().toString());
combinator(tq.consume());
} else if (seenWhite) {
combinator(" ");
combinator(' ');
} else { // E.class, E#id, E[attr] etc. AND
Elements candidates = findElements(); // take next el, #. etc off queue
intersectElements(filterForSelf(elements, candidates));
Expand All @@ -134,18 +134,18 @@ private Elements select() {
return new Elements(elements);
}

private void combinator(String combinator) {
private void combinator(char combinator) {
tq.consumeWhitespace();
String subQuery = tq.consumeToAny(combinators); // support multi > childs

Elements output;
if (combinator.equals(">"))
if (combinator == '>')
output = filterForChildren(elements, select(subQuery, elements));
else if (combinator.equals(" "))
else if (combinator == ' ')
output = filterForDescendants(elements, select(subQuery, elements));
else if (combinator.equals("+"))
else if (combinator == '+')
output = filterForAdjacentSiblings(elements, select(subQuery, root));
else if (combinator.equals("~"))
else if (combinator == '~')
output = filterForGeneralSiblings(elements, select(subQuery, root));
else
throw new IllegalStateException("Unknown combinator: " + combinator);
Expand Down

0 comments on commit 2dd2968

Please sign in to comment.