Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
7ad501b1
提交
7ad501b1
authored
15 年前
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
A bit faster.
上级
d5bb9cb7
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
14 行增加
和
12 行删除
+14
-12
CompareLike.java
h2/src/main/org/h2/expression/CompareLike.java
+14
-12
没有找到文件。
h2/src/main/org/h2/expression/CompareLike.java
浏览文件 @
7ad501b1
...
...
@@ -44,6 +44,7 @@ public class CompareLike extends Condition {
private
int
[]
types
;
private
int
patternLength
;
private
boolean
ignoreCase
;
private
boolean
fastCompare
;
public
CompareLike
(
CompareMode
compareMode
,
Expression
left
,
Expression
right
,
Expression
escape
,
boolean
regexp
)
{
this
.
compareMode
=
compareMode
;
...
...
@@ -221,22 +222,20 @@ public class CompareLike extends Condition {
// result = patternRegexp.matcher(value).matches();
result
=
patternRegexp
.
matcher
(
value
).
find
();
}
else
{
result
=
compareAt
(
value
,
0
,
0
,
value
.
length
());
result
=
compareAt
(
value
,
0
,
0
,
value
.
length
()
,
pattern
,
types
);
}
return
ValueBoolean
.
get
(
result
);
}
private
boolean
compare
(
String
s
,
int
pi
,
int
si
)
{
// TODO check if this is correct according to Unicode rules (code points)
return
compareMode
.
equalsChars
(
patternString
,
pi
,
s
,
si
,
ignoreCase
);
private
boolean
compare
(
char
[]
pattern
,
String
s
,
int
pi
,
int
si
)
{
return
pattern
[
pi
]
==
s
.
charAt
(
si
)
||
(!
fastCompare
&&
compareMode
.
equalsChars
(
patternString
,
pi
,
s
,
si
,
ignoreCase
));
}
private
boolean
compareAt
(
String
s
,
int
pi
,
int
si
,
int
sLen
)
{
private
boolean
compareAt
(
String
s
,
int
pi
,
int
si
,
int
sLen
,
char
[]
pattern
,
int
[]
types
)
{
for
(;
pi
<
patternLength
;
pi
++)
{
int
type
=
types
[
pi
];
switch
(
type
)
{
switch
(
types
[
pi
])
{
case
MATCH:
if
((
si
>=
sLen
)
||
!
compare
(
s
,
pi
,
si
++))
{
if
((
si
>=
sLen
)
||
!
compare
(
pattern
,
s
,
pi
,
si
++))
{
return
false
;
}
break
;
...
...
@@ -250,14 +249,14 @@ public class CompareLike extends Condition {
return
true
;
}
while
(
si
<
sLen
)
{
if
(
compare
(
s
,
pi
,
si
)
&&
compareAt
(
s
,
pi
,
si
,
sLen
))
{
if
(
compare
(
pattern
,
s
,
pi
,
si
)
&&
compareAt
(
s
,
pi
,
si
,
sLen
,
pattern
,
types
))
{
return
true
;
}
si
++;
}
return
false
;
default
:
Message
.
throwInternalError
(
"type="
+
type
);
Message
.
throwInternalError
();
}
}
return
si
==
sLen
;
...
...
@@ -273,10 +272,13 @@ public class CompareLike extends Condition {
*/
public
boolean
test
(
String
testPattern
,
String
value
,
char
escapeChar
)
throws
SQLException
{
initPattern
(
testPattern
,
escapeChar
);
return
compareAt
(
value
,
0
,
0
,
value
.
length
());
return
compareAt
(
value
,
0
,
0
,
value
.
length
()
,
pattern
,
types
);
}
private
void
initPattern
(
String
p
,
Character
escape
)
throws
SQLException
{
if
(
compareMode
.
getName
().
equals
(
CompareMode
.
OFF
)
&&
!
ignoreCase
)
{
fastCompare
=
true
;
}
if
(
regexp
)
{
patternString
=
p
;
try
{
...
...
@@ -286,7 +288,7 @@ public class CompareLike extends Condition {
patternRegexp
=
Pattern
.
compile
(
p
);
}
}
catch
(
PatternSyntaxException
e
)
{
throw
Message
.
getSQLException
(
ErrorCode
.
LIKE_ESCAPE_ERROR_1
,
new
String
[]{
p
},
e
);
throw
Message
.
getSQLException
(
ErrorCode
.
LIKE_ESCAPE_ERROR_1
,
e
,
p
);
}
return
;
}
...
...
This diff is collapsed.
Click to expand it.
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论