Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
6f649601
D
dragonwell8_jdk
项目概览
openanolis
/
dragonwell8_jdk
通知
4
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dragonwell8_jdk
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
6f649601
编写于
1月 13, 2010
作者:
P
peytoia
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
6868503: RuleBasedBreakIterator is inefficient
Reviewed-by: okutsu
上级
6140c8ba
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
27 addition
and
4 deletion
+27
-4
src/share/classes/java/text/RuleBasedBreakIterator.java
src/share/classes/java/text/RuleBasedBreakIterator.java
+27
-4
未找到文件。
src/share/classes/java/text/RuleBasedBreakIterator.java
浏览文件 @
6f649601
...
@@ -621,6 +621,8 @@ class RuleBasedBreakIterator extends BreakIterator {
...
@@ -621,6 +621,8 @@ class RuleBasedBreakIterator extends BreakIterator {
return
handleNext
();
return
handleNext
();
}
}
private
int
cachedLastKnownBreak
=
BreakIterator
.
DONE
;
/**
/**
* Advances the iterator backwards, to the last boundary preceding this one.
* Advances the iterator backwards, to the last boundary preceding this one.
* @return The position of the last boundary position preceding this one.
* @return The position of the last boundary position preceding this one.
...
@@ -638,8 +640,16 @@ class RuleBasedBreakIterator extends BreakIterator {
...
@@ -638,8 +640,16 @@ class RuleBasedBreakIterator extends BreakIterator {
// the current position), but not necessarily the last one before
// the current position), but not necessarily the last one before
// where we started
// where we started
int
start
=
current
();
int
start
=
current
();
getPrevious
();
int
lastResult
=
cachedLastKnownBreak
;
int
lastResult
=
handlePrevious
();
if
(
lastResult
>=
start
||
lastResult
<=
BreakIterator
.
DONE
)
{
getPrevious
();
lastResult
=
handlePrevious
();
}
else
{
//it might be better to check if handlePrevious() give us closer
//safe value but handlePrevious() is slow too
//So, this has to be done carefully
text
.
setIndex
(
lastResult
);
}
int
result
=
lastResult
;
int
result
=
lastResult
;
// iterate forward from the known break position until we pass our
// iterate forward from the known break position until we pass our
...
@@ -653,6 +663,7 @@ class RuleBasedBreakIterator extends BreakIterator {
...
@@ -653,6 +663,7 @@ class RuleBasedBreakIterator extends BreakIterator {
// set the current iteration position to be the last break position
// set the current iteration position to be the last break position
// before where we started, and then return that value
// before where we started, and then return that value
text
.
setIndex
(
lastResult
);
text
.
setIndex
(
lastResult
);
cachedLastKnownBreak
=
lastResult
;
return
lastResult
;
return
lastResult
;
}
}
...
@@ -757,7 +768,8 @@ class RuleBasedBreakIterator extends BreakIterator {
...
@@ -757,7 +768,8 @@ class RuleBasedBreakIterator extends BreakIterator {
// then we can just use next() to get our return value
// then we can just use next() to get our return value
text
.
setIndex
(
offset
);
text
.
setIndex
(
offset
);
if
(
offset
==
text
.
getBeginIndex
())
{
if
(
offset
==
text
.
getBeginIndex
())
{
return
handleNext
();
cachedLastKnownBreak
=
handleNext
();
return
cachedLastKnownBreak
;
}
}
// otherwise, we have to sync up first. Use handlePrevious() to back
// otherwise, we have to sync up first. Use handlePrevious() to back
...
@@ -767,10 +779,19 @@ class RuleBasedBreakIterator extends BreakIterator {
...
@@ -767,10 +779,19 @@ class RuleBasedBreakIterator extends BreakIterator {
// position at or before our starting position. Advance forward
// position at or before our starting position. Advance forward
// from here until we've passed the starting position. The position
// from here until we've passed the starting position. The position
// we stop on will be the first break position after the specified one.
// we stop on will be the first break position after the specified one.
int
result
=
handlePrevious
();
int
result
=
cachedLastKnownBreak
;
if
(
result
>=
offset
||
result
<=
BreakIterator
.
DONE
)
{
result
=
handlePrevious
();
}
else
{
//it might be better to check if handlePrevious() give us closer
//safe value but handlePrevious() is slow too
//So, this has to be done carefully
text
.
setIndex
(
result
);
}
while
(
result
!=
BreakIterator
.
DONE
&&
result
<=
offset
)
{
while
(
result
!=
BreakIterator
.
DONE
&&
result
<=
offset
)
{
result
=
handleNext
();
result
=
handleNext
();
}
}
cachedLastKnownBreak
=
result
;
return
result
;
return
result
;
}
}
...
@@ -865,6 +886,8 @@ class RuleBasedBreakIterator extends BreakIterator {
...
@@ -865,6 +886,8 @@ class RuleBasedBreakIterator extends BreakIterator {
text
=
new
SafeCharIterator
(
newText
);
text
=
new
SafeCharIterator
(
newText
);
}
}
text
.
first
();
text
.
first
();
cachedLastKnownBreak
=
BreakIterator
.
DONE
;
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录