Merge "Small optimization for readability"
commit
2023975988
|
@ -178,8 +178,14 @@ public final class KeyboardLayoutSet {
|
||||||
|
|
||||||
private Keyboard getKeyboard(final ElementParams elementParams, final KeyboardId id) {
|
private Keyboard getKeyboard(final ElementParams elementParams, final KeyboardId id) {
|
||||||
final SoftReference<Keyboard> ref = sKeyboardCache.get(id);
|
final SoftReference<Keyboard> ref = sKeyboardCache.get(id);
|
||||||
Keyboard keyboard = (ref == null) ? null : ref.get();
|
final Keyboard cachedKeyboard = (ref == null) ? null : ref.get();
|
||||||
if (keyboard == null) {
|
if (cachedKeyboard != null) {
|
||||||
|
if (DEBUG_CACHE) {
|
||||||
|
Log.d(TAG, "keyboard cache size=" + sKeyboardCache.size() + ": HIT id=" + id);
|
||||||
|
}
|
||||||
|
return cachedKeyboard;
|
||||||
|
}
|
||||||
|
|
||||||
final KeyboardBuilder<KeyboardParams> builder =
|
final KeyboardBuilder<KeyboardParams> builder =
|
||||||
new KeyboardBuilder<KeyboardParams>(mContext, new KeyboardParams());
|
new KeyboardBuilder<KeyboardParams>(mContext, new KeyboardParams());
|
||||||
if (id.isAlphabetKeyboard()) {
|
if (id.isAlphabetKeyboard()) {
|
||||||
|
@ -190,9 +196,8 @@ public final class KeyboardLayoutSet {
|
||||||
if (mParams.mDisableTouchPositionCorrectionDataForTest) {
|
if (mParams.mDisableTouchPositionCorrectionDataForTest) {
|
||||||
builder.disableTouchPositionCorrectionDataForTest();
|
builder.disableTouchPositionCorrectionDataForTest();
|
||||||
}
|
}
|
||||||
builder.setProximityCharsCorrectionEnabled(
|
builder.setProximityCharsCorrectionEnabled(elementParams.mProximityCharsCorrectionEnabled);
|
||||||
elementParams.mProximityCharsCorrectionEnabled);
|
final Keyboard keyboard = builder.build();
|
||||||
keyboard = builder.build();
|
|
||||||
sKeyboardCache.put(id, new SoftReference<Keyboard>(keyboard));
|
sKeyboardCache.put(id, new SoftReference<Keyboard>(keyboard));
|
||||||
if ((id.mElementId == KeyboardId.ELEMENT_ALPHABET
|
if ((id.mElementId == KeyboardId.ELEMENT_ALPHABET
|
||||||
|| id.mElementId == KeyboardId.ELEMENT_ALPHABET_AUTOMATIC_SHIFTED)
|
|| id.mElementId == KeyboardId.ELEMENT_ALPHABET_AUTOMATIC_SHIFTED)
|
||||||
|
@ -210,10 +215,6 @@ public final class KeyboardLayoutSet {
|
||||||
Log.d(TAG, "keyboard cache size=" + sKeyboardCache.size() + ": "
|
Log.d(TAG, "keyboard cache size=" + sKeyboardCache.size() + ": "
|
||||||
+ ((ref == null) ? "LOAD" : "GCed") + " id=" + id);
|
+ ((ref == null) ? "LOAD" : "GCed") + " id=" + id);
|
||||||
}
|
}
|
||||||
} else if (DEBUG_CACHE) {
|
|
||||||
Log.d(TAG, "keyboard cache size=" + sKeyboardCache.size() + ": HIT id=" + id);
|
|
||||||
}
|
|
||||||
|
|
||||||
return keyboard;
|
return keyboard;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue