Skip to content

Commit bb05e95

Browse files
kkmp911de
authored andcommitted
Polishing
[closes #478] Signed-off-by: Mark Paluch <mpaluch@vmware.com>
1 parent f8afcad commit bb05e95

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

src/main/java/io/r2dbc/postgresql/PostgresqlSqlLexer.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,12 +124,12 @@ private static boolean isSpecialOrOperatorChar(char c) {
124124
private static TokenizedSql.Token getBlockCommentToken(String sql, int beginIndex) {
125125
int depth = 1;
126126
for (int i = beginIndex + 2; i < (sql.length() - 1); i++) {
127-
String biGraph = sql.substring(i, i + 2);
128-
129-
if (biGraph.equals("/*")) {
127+
char c1 = sql.charAt(i);
128+
char c2 = sql.charAt(i + 1);
129+
if (c1 == '/' && c2 == '*') {
130130
depth++;
131131
i++;
132-
} else if (biGraph.equals("*/")) {
132+
} else if (c1 == '*' && c2 == '/') {
133133
depth--;
134134
i++;
135135
}

src/test/java/io/r2dbc/postgresql/PostgresqlSqlLexerTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ void lineCommentIsTokenized() {
6161
@Test
6262
void cStyleCommentIsTokenized() {
6363
assertSingleStatementEqualsCompleteToken("/*Test*/", TokenizedSql.TokenType.COMMENT);
64+
assertSingleStatementEqualsCompleteToken("/**/", TokenizedSql.TokenType.COMMENT);
65+
assertSingleStatementEqualsCompleteToken("/*T*/", TokenizedSql.TokenType.COMMENT);
6466
}
6567

6668
@Test

0 commit comments

Comments
 (0)