Skip to content

Commit

Permalink
Optimize Space#withWhitespace() for formatting
Browse files Browse the repository at this point in the history
Return `SINGLE_SPACE` as appropriate.
  • Loading branch information
knutwannheden committed Sep 1, 2023
1 parent 9e2db96 commit 965df22
Showing 1 changed file with 2 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ public Space withComments(List<Comment> comments) {
public Space withWhitespace(String whitespace) {
if (comments.isEmpty() && whitespace.isEmpty()) {
return Space.EMPTY;
} else if (comments.isEmpty() && " ".equals(whitespace)) {
return SINGLE_SPACE;
}
if ((whitespace.isEmpty() && this.whitespace == null) || whitespace.equals(this.whitespace)) {
return this;
Expand Down

0 comments on commit 965df22

Please sign in to comment.