url resolve_tex (url name) { string s= as_string (name); if (is_cached ("font_cache.scm", s)) { url u= url_system (cache_get ("font_cache.scm", s) -> label); if (exists (u)) return u; cache_reset ("font_cache.scm", s); } bench_start ("resolve tex"); url u= url_none (); if (ends (s, "mf" )) { u= resolve_tfm (name); #ifdef OS_WIN32 if (is_none (u)) u= resolve_tfm (replace (s, ".mf", ".tfm")); #endif } if (ends (s, "tfm")) u= resolve_tfm (name); if (ends (s, "pk" )) u= resolve_pk (name); if (ends (s, "pfb")) u= resolve_pfb (name); bench_cumul ("resolve tex"); if (!is_none (u)) cache_set ("font_cache.scm", s, as_string (u)); //cout << "Resolve " << name << " -> " << u << "\n"; return u; }
bool is_up_to_date (url dir) { string name_dir= concretize (dir); if (cache_valid->contains (name_dir)) return cache_valid [name_dir]; int l= last_modified (dir, false); if (is_cached ("validate_cache.scm", name_dir)) { int r= as_int (cache_get ("validate_cache.scm", name_dir) -> label); if (l == r) { cache_valid (name_dir)= true; return true; } //cout << name_dir << " no longer up to date " << r << " -> " << l << "\n"; } //else cout << name_dir << " not up to date " << l << "\n"; cache_set ("validate_cache.scm", name_dir, as_string (l)); cache_valid (name_dir)= false; // FIXME: we should explicitly remove all data concerning files in 'dir' // from the various caches. Indeed, at a next run of TeXmacs, the directory // will be regarded as up to date, but the other caches may still contain // outdated data. Careful: invalidating the cache lines should not // give rise to a performance penaly (e.g. go through all entries of // 'cache_data', or reloading unchanged files many times). // See also 'declare_out_of_date'. return false; }
size_t XplodifyPlaylist::get_num_tracks(bool cache){ track_cache_by_rand& t_r = m_track_cache.get<0>(); if(cache && is_cached()) { return m_num_tracks; } return t_r.size(); }
//when we put in Exceptions this will be a lot cleaner. std::string XplodifyPlaylist::get_name(bool cache) { if(!m_playlist) { return std::string(""); } if(cache && is_cached()) { return m_name; } return std::string(sp_playlist_name(m_playlist)); }
u_int acl::get_permissions (sfsauth_cred *cred, str *key, vec<sfs_idname> *groups) { vec<str> credstrings; u_int p = 0; // 3 kinds of access: anonymous, public key, unix credentials // anonymous means that the user wasn't running an agent or // for some reason the authd couldn't even return a public key if (key) credstrings.push_back (strbuf () << TYPEPK << ACLDIV << *key); if (cred) credstrings.push_back (strbuf () << TYPELOCALUSER << ACLDIV << cred->unixcred->username); if (groups) { for (unsigned int i = 0; i < groups->size (); i++) credstrings.push_back (strbuf () << TYPELOCALGROUP << ACLDIV << (*groups)[i]); } if (!cred && !key) credstrings.push_back (strbuf () << TYPESYS << ACLDIV << SYS_ANONYMOUS); str flattened_creds (""); for (u_int i = 0; i < credstrings.size (); i++) { warn ("CRED[%d]: %s\n", i, credstrings[i].cstr ()); flattened_creds = strbuf () << flattened_creds << credstrings[i]; } #if PCACHE //make hash out of acl and user; ask cache about hash str ua = strbuf () << armor32 (str (aclhash, sizeof (aclhash))) << flattened_creds; bzero (hashbuf, sizeof (hashbuf)); sha1_hash (hashbuf, ua.cstr (), ua.len ()); if (is_cached (hashbuf, p)) { warn << "Using cached perms (" << get_strpermissions (p) << ") for cache key "<< armor32 (str (hashbuf, sizeof (hashbuf))) << "\n"; return p; } else { warn << "Did not find cached perms (" << ua << ") for cache key " << armor32 (str (hashbuf, sizeof (hashbuf))) << "\n"; } #endif p = parse_acl (credstrings); #if PCACHE insert_cache (hashbuf, p); #endif return p; }
bool load_tex_tfm (string family, int size, int dsize, tex_font_metric& tfm) { string var= "tfm:" * family * as_string (size); if (is_cached ("font_cache.scm", var)) if (try_tfm (family, as_int (cache_get ("font_cache.scm", var)->label), size, tfm, false)) return true; if (get_setting ("MAKETFM") != "false") if (load_tex_tfm (family, size ,dsize, tfm, false)) return true; return load_tex_tfm (family, size ,dsize, tfm, true); }
void XplodifyPlaylist::cache(void) { if (is_cached()) { return; } m_name = get_name(); m_num_tracks = get_num_tracks(); m_cached = true; return; }
subpaving::var process(expr * t, unsigned depth, mpz & n, mpz & d) { SASSERT(is_int_real(t)); checkpoint(); if (is_cached(t)) { unsigned idx = m_cache.find(t); qm().set(n, m_cached_numerators[idx]); qm().set(d, m_cached_denominators[idx]); return m_cached_vars[idx]; } SASSERT(!is_quantifier(t)); if (::is_var(t) || !m_autil.is_arith_expr(t)) { qm().set(n, 1); qm().set(d, 1); return mk_var_for(t); } return process_arith_app(to_app(t), depth, n, d); }
void distribute_forall::reduce1_app(app * a) { SASSERT(a); unsigned num_args = a->get_num_args(); unsigned j = num_args; bool reduced = false; m_new_args.reserve(num_args); app * na = a; while(j > 0) { --j; SASSERT(is_cached(a->get_arg(j))); expr * c = get_cached(a->get_arg(j)); SASSERT(c!=0); if (c != a->get_arg(j)) reduced = true; m_new_args[j] = c; } if (reduced) { na = m_manager.mk_app(a->get_decl(), num_args, m_new_args.c_ptr()); } cache_result(a, na); }
void distribute_forall::visit(expr * n, bool & visited) { if (!is_cached(n)) { m_todo.push_back(n); visited = false; } }