/* Maximum delta from the current time, in seconds, for a past time
* to qualify as "recent" for use in the ap_explode_recent_*() functions:
+ * (Must be a power of two minus one!)
*/
#define AP_TIME_RECENT_THRESHOLD 15
/* the "+ 1" is for the current second: */
#define TIME_CACHE_SIZE (AP_TIME_RECENT_THRESHOLD + 1)
+/* Note that AP_TIME_RECENT_THRESHOLD is defined to
+ * be a power of two minus one in util_time.h, so that
+ * we can replace a modulo operation with a bitwise AND
+ * when hashing items into a cache of size
+ * AP_TIME_RECENT_THRESHOLD+1
+ */
+#define TIME_CACHE_MASK (AP_TIME_RECENT_THRESHOLD)
+
static struct exploded_time_cache_element exploded_cache_localtime[TIME_CACHE_SIZE];
static struct exploded_time_cache_element exploded_cache_gmt[TIME_CACHE_SIZE];
{
apr_int64_t seconds = apr_time_sec(t);
struct exploded_time_cache_element *cache_element =
- &(cache[seconds % TIME_CACHE_SIZE]);
+ &(cache[seconds & TIME_CACHE_MASK]);
struct exploded_time_cache_element cache_element_snapshot;
/* The cache is implemented as a ring buffer. Each second,