Libraryless. Click here for Pure Java version (2144L/14K).
static Map<Class, HashMap<S, Method>> callOpt_noArgs_cache = newDangerousWeakHashMap(); static O callOpt_noArgs(O o, S method) ctex { if (o == null) ret null; if (o instanceof Class) ret callOpt(o, method); // not optimized Class c = o.getClass(); HashMap<S, Method> map; synchronized(callOpt_noArgs_cache) { map = callOpt_noArgs_cache.get(c); if (map == null) map = callOpt_noArgs_makeCache(c); } Method m = map.get(method); ret m != null ? m.invoke(o) : null; } // used internally - we are in synchronized block static HashMap<S, Method> callOpt_noArgs_makeCache(Class c) { new HashMap<S, Method> map; Class _c = c; do { for (Method m : c.getDeclaredMethods()) if (m.getParameterTypes().length == 0 && !reflection_isForbiddenMethod(m)) { makeAccessible(m); S name = m.getName(); if (!map.containsKey(name)) map.put(name, m); } _c = _c.getSuperclass(); } while (_c != null); callOpt_noArgs_cache.put(c, map); ret map; }
Began life as a copy of #1001199
download show line numbers debug dex old transpilations
Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ddnzoavkxhuk, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1005607 |
Snippet name: | callOpt_noArgs - optimized version of callOpt when you don't pass arguments |
Eternal ID of this version: | #1005607/5 |
Text MD5: | ac9de21476b927ab4ec9cc04e381721d |
Transpilation MD5: | a8c84bb572f1bd8ab6c67db467263145 |
Author: | stefan |
Category: | |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2019-08-31 14:51:15 |
Source code size: | 1071 bytes / 37 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 517 / 581 |
Version history: | 4 change(s) |
Referenced in: | #1006654 - Standard functions list 2 (LIVE, continuation of #761) |