MIRROR: javascript for ๐Ÿœ's, a tiny runtime with big ambitions
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

add koff cache for faster interned string lookup

+22 -2
+1 -1
meson.build
··· 74 74 build_date = run_command('date', '+%Y-%m-%d', check: true).stdout().strip() 75 75 76 76 version_conf = configuration_data() 77 - version_conf.set('ANT_VERSION', '0.2.1.6') 77 + version_conf.set('ANT_VERSION', '0.2.1.7') 78 78 version_conf.set('ANT_GIT_HASH', git_hash) 79 79 version_conf.set('ANT_BUILD_DATE', build_date) 80 80
+21 -1
src/ant.c
··· 2785 2785 return (koff >> 2) & (KOFF_BUCKETS - 1); 2786 2786 } 2787 2787 2788 + #define KOFF_CACHE_SIZE 2048 2789 + typedef struct { 2790 + jsoff_t koff; 2791 + const char *interned; 2792 + } koff_cache_entry_t; 2793 + static koff_cache_entry_t koff_cache[KOFF_CACHE_SIZE]; 2794 + 2788 2795 static inline const char *get_koff_intern(jsoff_t koff) { 2796 + uint32_t slot = (koff >> 2) & (KOFF_CACHE_SIZE - 1); 2797 + if (koff_cache[slot].koff == koff) { 2798 + return koff_cache[slot].interned; 2799 + } 2800 + 2789 2801 uint32_t bucket = koff_hash(koff); 2790 2802 for (koff_intern_t *e = koff_buckets[bucket]; e; e = e->next) { 2791 - if (e->koff == koff) return e->interned; 2803 + if (e->koff == koff) { 2804 + koff_cache[slot].koff = koff; 2805 + koff_cache[slot].interned = e->interned; 2806 + return e->interned; 2807 + } 2792 2808 } 2793 2809 return NULL; 2794 2810 } ··· 2804 2820 entry->interned = interned; 2805 2821 entry->next = koff_buckets[bucket]; 2806 2822 koff_buckets[bucket] = entry; 2823 + 2824 + uint32_t slot = (koff >> 2) & (KOFF_CACHE_SIZE - 1); 2825 + koff_cache[slot].koff = koff; 2826 + koff_cache[slot].interned = interned; 2807 2827 } 2808 2828 2809 2829 static inline uint64_t make_cache_key(jsoff_t obj_offset, uint32_t str_hash) {