abouttreesummaryrefslogcommitdiff
path: root/srcs/juloo.keyboard2
diff options
context:
space:
mode:
authorJules Aguillon2024-06-09 12:49:23 +0200
committerJules Aguillon2024-06-09 12:49:23 +0200
commit8d793da6b62cab5ef8f3d86e7d2b776abc22f0fb (patch)
tree33192a45a96d165c36df19bbdc2649dd045474fb /srcs/juloo.keyboard2
parent91ace060bc8c49f1ea4b8185e239a58ec7d5478a (diff)
downloadunexpected-keyboard-8d793da6b62cab5ef8f3d86e7d2b776abc22f0fb.tar.gz
unexpected-keyboard-8d793da6b62cab5ef8f3d86e7d2b776abc22f0fb.zip
Refactor: Remove the KeyModifier cache
Diffstat (limited to 'srcs/juloo.keyboard2')
-rw-r--r--srcs/juloo.keyboard2/KeyModifier.java32
1 files changed, 3 insertions, 29 deletions
diff --git a/srcs/juloo.keyboard2/KeyModifier.java b/srcs/juloo.keyboard2/KeyModifier.java
index cd18c30..8d5fbbb 100644
--- a/srcs/juloo.keyboard2/KeyModifier.java
+++ b/srcs/juloo.keyboard2/KeyModifier.java
@@ -6,19 +6,11 @@ import java.util.HashMap;
public final class KeyModifier
{
- /** Cache key is KeyValue's name */
- private static HashMap<KeyValue, HashMap<Pointers.Modifiers, KeyValue>> _cache =
- new HashMap<KeyValue, HashMap<Pointers.Modifiers, KeyValue>>();
-
/** The optional modmap takes priority over modifiers usual behaviors. Set to
[null] to disable. */
private static KeyboardData.Modmap _modmap = null;
public static void set_modmap(KeyboardData.Modmap mm)
{
- // Clear the cache when switching to or from a layout that contain a modmap
- // as the cache would otherwise override the modmap.
- if (_modmap != null || mm != null)
- _cache.clear();
_modmap = mm;
}
@@ -28,15 +20,9 @@ public final class KeyModifier
if (k == null)
return null;
int n_mods = mods.size();
- HashMap<Pointers.Modifiers, KeyValue> ks = cacheEntry(k);
- KeyValue r = ks.get(mods);
- if (r == null)
- {
- r = k;
- for (int i = 0; i < n_mods; i++)
- r = modify(r, mods.get(i));
- ks.put(mods, r);
- }
+ KeyValue r = k;
+ for (int i = 0; i < n_mods; i++)
+ r = modify(r, mods.get(i));
/* Keys with an empty string are placeholder keys. */
if (r.getString().length() == 0)
return null;
@@ -529,18 +515,6 @@ public final class KeyModifier
return shifted;
}
- /* Lookup the cache entry for a key. Create it needed. */
- private static HashMap<Pointers.Modifiers, KeyValue> cacheEntry(KeyValue k)
- {
- HashMap<Pointers.Modifiers, KeyValue> ks = _cache.get(k);
- if (ks == null)
- {
- ks = new HashMap<Pointers.Modifiers, KeyValue>();
- _cache.put(k, ks);
- }
- return ks;
- }
-
public static abstract class Map_char
{
/** Modify a char or return [null] if the modifier do not apply. Return a