void property_cache_set (repv id, repv prop, repv value, int invals) { unsigned int h, i, oldest, oldest_age; if (cache_vec == rep_NULL) { cache_vec = Fmake_vector (rep_MAKE_INT (CACHE_SIZE * 3), Qnil); rep_mark_static (&cache_vec); cache_ids = rep_VECT (cache_vec)->array; cache_props = cache_ids + CACHE_SIZE; cache_values = cache_props + CACHE_SIZE; } h = CACHE_HASH (id, prop) * CACHE_ASSOC; oldest_age = UINT_MAX; oldest = -1; for (i = h; i < h + CACHE_ASSOC; i++) { if (cache_ids[i] == id && cache_props[i] == prop) { cache_values[i] = value; cache_updates[i] += invals; return; } if (cache_ages[i] <= oldest_age) { oldest_age = cache_ages[i]; oldest = i; } } assert (oldest != -1); if (cache_ids[oldest] != 0) DB (("prop eject: 0x%x (%d)\n", cache_ids[oldest], oldest)); cache_ids[oldest] = id; cache_props[oldest] = prop; cache_values[oldest] = value; cache_ages[oldest] = ++cache_clock; cache_updates[oldest] = invals; DB (("set: 0x%x,%s (%d)\n", id, rep_STR (rep_SYM (prop)->name), oldest)); }
void init_menu_items (void) { if (!NILP (menu_items_inuse)) error ("Trying to use a menu from within a menu-entry"); if (NILP (menu_items)) { menu_items_allocated = 60; menu_items = Fmake_vector (make_number (menu_items_allocated), Qnil); } menu_items_inuse = Qt; menu_items_used = 0; menu_items_n_panes = 0; menu_items_submenu_depth = 0; }
static Lisp_Object make_log (int heap_size, int max_stack_depth) { /* We use a standard Elisp hash-table object, but we use it in a special way. This is OK as long as the object is not exposed to Elisp, i.e. until it is returned by *-profiler-log, after which it can't be used any more. */ Lisp_Object log = make_hash_table (hashtest_profiler, make_number (heap_size), make_float (DEFAULT_REHASH_SIZE), make_float (DEFAULT_REHASH_THRESHOLD), Qnil); struct Lisp_Hash_Table *h = XHASH_TABLE (log); /* What is special about our hash-tables is that the keys are pre-filled with the vectors we'll put in them. */ int i = ASIZE (h->key_and_value) / 2; while (i > 0) set_hash_key_slot (h, --i, Fmake_vector (make_number (max_stack_depth), Qnil)); return log; }
repv gh_make_vector(repv length, repv val) { return Fmake_vector (length, val); }