SDL: hashtable: Don't rearrange bucket elements during SDL_FindInHashTable.

From 66644377480887eeacafbccdba3b8a458fa696c9 Mon Sep 17 00:00:00 2001
From: "Ryan C. Gordon" <[EMAIL REDACTED]>
Date: Sat, 14 Oct 2023 13:52:50 -0400
Subject: [PATCH] hashtable: Don't rearrange bucket elements during

This is a race condition if the hashtable isn't protected by a mutex, and it
makes a read/write operation out of something what appears to be read-only,
which is dangerously surprising from an interface viewpoint.

The downside is that if you have an item that is frequently accessed that
isn't in the first slot of a bucket, each find operation will take longer
instead of common items bubbling to the front of the bucket. Then again,
if you have several common things being looked up in rotation, they'll just
be doing unnecessary shuffling here. In this case, it might be better to
just use a larger hashtable or a better hashing function (or just look up the
thing you need once instead of multiple times).

Fixes #8391.
 src/SDL_hashtable.c | 10 ----------
 1 file changed, 10 deletions(-)

diff --git a/src/SDL_hashtable.c b/src/SDL_hashtable.c
index e2714d132149..5646a3717f30 100644
--- a/src/SDL_hashtable.c
+++ b/src/SDL_hashtable.c
@@ -116,16 +116,6 @@ SDL_bool SDL_FindInHashTable(const SDL_HashTable *table, const void *key, const
             if (_value != NULL) {
                 *_value = i->value;
-            /* Matched! Move to the front of list for faster lookup next time.
-               (stackable tables have to remain in the same order, though!) */
-            if ((!table->stackable) && (prev != NULL)) {
-                SDL_assert(prev->next == i);
-                prev->next = i->next;
-                i->next = table->table[hash];
-                table->table[hash] = i;
-            }
             return SDL_TRUE;