Commit Graph

8 Commits

Author SHA1 Message Date
Sam Lantinga f3261fedcc Code cleanup now that SDL_bool is equivalent to a C boolean expression 2023-11-03 09:54:04 -07:00
Ryan C. Gordon 8df68b4120
hashtable: Moved over to single-line comments. 2023-10-15 15:41:04 -04:00
Anonymous Maarten e526dc64bd Don't set unused variable 2023-10-15 01:36:49 +02:00
Ryan C. Gordon 6664437748
hashtable: Don't rearrange bucket elements during SDL_FindInHashTable.
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.
2023-10-14 13:56:56 -04:00
Ryan C. Gordon 0aba2c97db
hashtable: SDL_IterateHashTable might as well provide both key and value.
And SDL_IterateHashTableKey is only necessary for stackable hashtables, since
non-stackable ones can either iterate each unique key/value pair with
SDL_IterateHashTable, or get a specific key/value pair by using
SDL_FindInHashTable.
2023-10-14 13:23:03 -04:00
Sam Lantinga 973c8b3273 Added SDL properties API
Fixes https://github.com/libsdl-org/SDL/issues/7799
2023-10-11 22:38:00 -07:00
Ryan C. Gordon 8e03ea4383
hashtable: Use Create/Destroy naming, in the SDL3 style. 2023-10-09 19:20:43 -04:00
Ryan C. Gordon 568902b64e
hashtable: Added src/SDL_hashtable.[ch].
Reference Issue #7799.
2023-10-09 19:19:01 -04:00