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