Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
LatinIME
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
keyboard
LatinIME
Commits
0016d51a
Commit
0016d51a
authored
11 years ago
by
Tadashi G. Takaoka
Browse files
Options
Downloads
Patches
Plain Diff
Small optimization for readability
Change-Id: I8a24fc0981e58a7dc30f0577c4415a1d3bc5ed4d
parent
95f9b95d
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
java/src/com/android/inputmethod/keyboard/KeyboardLayoutSet.java
+32
-31
32 additions, 31 deletions
...c/com/android/inputmethod/keyboard/KeyboardLayoutSet.java
with
32 additions
and
31 deletions
java/src/com/android/inputmethod/keyboard/KeyboardLayoutSet.java
+
32
−
31
View file @
0016d51a
...
...
@@ -178,42 +178,43 @@ public final class KeyboardLayoutSet {
private
Keyboard
getKeyboard
(
final
ElementParams
elementParams
,
final
KeyboardId
id
)
{
final
SoftReference
<
Keyboard
>
ref
=
sKeyboardCache
.
get
(
id
);
Keyboard
keyboard
=
(
ref
==
null
)
?
null
:
ref
.
get
();
if
(
keyboard
==
null
)
{
final
KeyboardBuilder
<
KeyboardParams
>
builder
=
new
KeyboardBuilder
<
KeyboardParams
>(
mContext
,
new
KeyboardParams
());
if
(
id
.
isAlphabetKeyboard
())
{
builder
.
setAutoGenerate
(
sKeysCache
);
}
final
int
keyboardXmlId
=
elementParams
.
mKeyboardXmlId
;
builder
.
load
(
keyboardXmlId
,
id
);
if
(
mParams
.
mDisableTouchPositionCorrectionDataForTest
)
{
builder
.
disableTouchPositionCorrectionDataForTest
();
final
Keyboard
cachedKeyboard
=
(
ref
==
null
)
?
null
:
ref
.
get
();
if
(
cachedKeyboard
!=
null
)
{
if
(
DEBUG_CACHE
)
{
Log
.
d
(
TAG
,
"keyboard cache size="
+
sKeyboardCache
.
size
()
+
": HIT id="
+
id
);
}
builder
.
setProximityCharsCorrectionEnabled
(
elementParams
.
mProximityCharsCorrectionEnabled
);
keyboard
=
builder
.
build
();
sKeyboardCache
.
put
(
id
,
new
SoftReference
<
Keyboard
>(
keyboard
));
if
((
id
.
mElementId
==
KeyboardId
.
ELEMENT_ALPHABET
||
id
.
mElementId
==
KeyboardId
.
ELEMENT_ALPHABET_AUTOMATIC_SHIFTED
)
&&
!
mParams
.
mIsSpellChecker
)
{
// We only forcibly cache the primary, "ALPHABET", layouts.
for
(
int
i
=
sForcibleKeyboardCache
.
length
-
1
;
i
>=
1
;
--
i
)
{
sForcibleKeyboardCache
[
i
]
=
sForcibleKeyboardCache
[
i
-
1
];
}
sForcibleKeyboardCache
[
0
]
=
keyboard
;
if
(
DEBUG_CACHE
)
{
Log
.
d
(
TAG
,
"forcing caching of keyboard with id="
+
id
);
}
return
cachedKeyboard
;
}
final
KeyboardBuilder
<
KeyboardParams
>
builder
=
new
KeyboardBuilder
<
KeyboardParams
>(
mContext
,
new
KeyboardParams
());
if
(
id
.
isAlphabetKeyboard
())
{
builder
.
setAutoGenerate
(
sKeysCache
);
}
final
int
keyboardXmlId
=
elementParams
.
mKeyboardXmlId
;
builder
.
load
(
keyboardXmlId
,
id
);
if
(
mParams
.
mDisableTouchPositionCorrectionDataForTest
)
{
builder
.
disableTouchPositionCorrectionDataForTest
();
}
builder
.
setProximityCharsCorrectionEnabled
(
elementParams
.
mProximityCharsCorrectionEnabled
);
final
Keyboard
keyboard
=
builder
.
build
();
sKeyboardCache
.
put
(
id
,
new
SoftReference
<
Keyboard
>(
keyboard
));
if
((
id
.
mElementId
==
KeyboardId
.
ELEMENT_ALPHABET
||
id
.
mElementId
==
KeyboardId
.
ELEMENT_ALPHABET_AUTOMATIC_SHIFTED
)
&&
!
mParams
.
mIsSpellChecker
)
{
// We only forcibly cache the primary, "ALPHABET", layouts.
for
(
int
i
=
sForcibleKeyboardCache
.
length
-
1
;
i
>=
1
;
--
i
)
{
sForcibleKeyboardCache
[
i
]
=
sForcibleKeyboardCache
[
i
-
1
];
}
sForcibleKeyboardCache
[
0
]
=
keyboard
;
if
(
DEBUG_CACHE
)
{
Log
.
d
(
TAG
,
"keyboard cache size="
+
sKeyboardCache
.
size
()
+
": "
+
((
ref
==
null
)
?
"LOAD"
:
"GCed"
)
+
" id="
+
id
);
Log
.
d
(
TAG
,
"forcing caching of keyboard with id="
+
id
);
}
}
else
if
(
DEBUG_CACHE
)
{
Log
.
d
(
TAG
,
"keyboard cache size="
+
sKeyboardCache
.
size
()
+
": HIT id="
+
id
);
}
if
(
DEBUG_CACHE
)
{
Log
.
d
(
TAG
,
"keyboard cache size="
+
sKeyboardCache
.
size
()
+
": "
+
((
ref
==
null
)
?
"LOAD"
:
"GCed"
)
+
" id="
+
id
);
}
return
keyboard
;
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment