Skip to content

Commit 2771ad5

Browse files
committed
Revert mime-table optimization, partially
Since bsearch() only compares the key itself with the other values from the array, this optimization would never work, as compare_mime_entry() would never be called with pointers from the mime extension table.
1 parent 5342311 commit 2771ad5

File tree

1 file changed

+2
-19
lines changed

1 file changed

+2
-19
lines changed

src/lib/lwan-tables.c

+2-19
Original file line numberDiff line numberDiff line change
@@ -122,25 +122,8 @@ LWAN_SELF_TEST(status_codes)
122122

123123
static int compare_mime_entry(const void *a, const void *b)
124124
{
125-
static const uintptr_t begin = (uintptr_t)uncompressed_mime_entries;
126-
static const uintptr_t end = begin + 8 * MIME_ENTRIES;
127-
const uintptr_t pa = (uintptr_t)a;
128-
const uintptr_t pb = (uintptr_t)b;
129-
uint64_t exta;
130-
uint64_t extb;
131-
132-
if (end - pa >= begin && end - pb >= begin) {
133-
/* If both keys are within the uncompressed mime entries range, then
134-
* we don't need to load from memory, just compare the pointers: they're
135-
* all stored sequentially in memory by construction. */
136-
exta = pa;
137-
extb = pb;
138-
} else {
139-
/* These are stored in big-endian so the comparison below works
140-
* as expected. */
141-
exta = string_as_uint64((const char *)a);
142-
extb = string_as_uint64((const char *)b);
143-
}
125+
const uint64_t exta = string_as_uint64((const char *)a);
126+
const uint64_t extb = string_as_uint64((const char *)b);
144127

145128
return (exta > extb) - (exta < extb);
146129
}

0 commit comments

Comments
 (0)