static HashMap, Class> loadFunctions_cache = new HashMap; static Lock loadFunctions_cached_lock = lock(); sbool loadFunctions_preferDiskCache; // Note: This may use outdated versions of standard functions static Class loadFunctions_cached(S... functions) { ret loadFunctions_cached(asList(functions)); } static Class loadFunctions_cached(Collection functions) { TreeSet functionSet = new TreeSet(functions); lock loadFunctions_cached_lock; Class c = loadFunctions_cache.get(functionSet); if (c != null) ret c; S transpilation = null; // new mode for slow machines (Raspberry Pi): get server transpilation if (l(functions) == 1 && isSlowMachine()) { S snippetID = stdFunctions_cached().get(first(functions)); if (nempty(snippetID)) { if (!isMD5(getUpToDateSnippetTranspilationMD5(snippetID))) print("Slow machine mode: " + snippetID + " transpilation not up to date"); else { transpilation = getServerTranspiledWithoutLibs(snippetID); // TODO: libs? print("Loaded server transpilation: " + snippetID); } } } if (transpilation == null) { S cached = getTranspiledStandardFunctionsIfCached(functionSet); // TODO: make sure we're using an up-to-date transpiler too if (cached != null && (loadFunctions_preferDiskCache || standardFunctionsCacheUpToDate(functionSet))) transpilation = cached; } if (transpilation != null) { // TODO: LIBS print("Loading " + joinWithPlus(functionSet)); c = veryQuickJava_finish(transpilation, emptyList()); } if (c == null) c = loadFunctions(functionSet); loadFunctions_cache.put(functionSet, c); assertNotNull(loadFunctions_cache.get(functionSet)); ret c; } svoid loadFunctions_cached_clearCache() { lock loadFunctions_cached_lock; loadFunctions_cache.clear(); } svoid _onLoad_loadFunctions_cached { ownResource(vmBus_onMessage('refreshedTranspiler, r loadFunctions_clearCache)); }