Libraryless. Click here for Pure Java version (2817L/17K).
static final Map<Class, _MethodCache> callOpt_cache = newDangerousWeakHashMap(); static O callOpt_cached(O o, S methodName, O... args) ctex { if (o == null) null; if (o instanceof Class) { Class c = (Class) o; _MethodCache cache = callOpt_getCache(c); // TODO: (super-rare) case where method exists static and non-static // with different args Method me = cache.findMethod(methodName, args); if (me == null || (me.getModifiers() & Modifier.STATIC) == 0) null; ret invokeMethod(me, null, args); } else { Class c = o.getClass(); _MethodCache cache = callOpt_getCache(c); Method me = cache.findMethod(methodName, args); if (me == null) null; ret invokeMethod(me, o, args); } } // no longer synchronizes! (see #1102990) static _MethodCache callOpt_getCache(Class c) { _MethodCache cache = callOpt_cache.get(c); if (cache == null) callOpt_cache.put(c, cache = _MethodCache(c)); ret cache; }
Began life as a copy of #1005583
download show line numbers debug dex old transpilations
Travelled to 15 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mowyntqkapby, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv
No comments. add comment
Snippet ID: | #1018497 |
Snippet name: | callOpt_cached (optimized version of callOpt) |
Eternal ID of this version: | #1018497/10 |
Text MD5: | 73a3166f4054df018e85d66a42a17443 |
Transpilation MD5: | ca8018bc2f769363f5f7459f33c01e1a |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2021-06-22 12:09:53 |
Source code size: | 998 bytes / 32 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 452 / 569 |
Version history: | 9 change(s) |
Referenced in: | [show references] |