mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-09-29 14:38:29 +00:00
Make SDL_ObjectValid() inline for performance (thanks @mechakotik!)
This commit is contained in:
@@ -137,7 +137,7 @@ Uint32 SDL_GetNextObjectID(void)
|
|||||||
|
|
||||||
static SDL_InitState SDL_objects_init;
|
static SDL_InitState SDL_objects_init;
|
||||||
static SDL_HashTable *SDL_objects;
|
static SDL_HashTable *SDL_objects;
|
||||||
static bool SDL_object_validation;
|
bool SDL_object_validation = false;
|
||||||
|
|
||||||
static void SDLCALL SDL_InvalidParamChecksChanged(void *userdata, const char *name, const char *oldValue, const char *hint)
|
static void SDLCALL SDL_InvalidParamChecksChanged(void *userdata, const char *name, const char *oldValue, const char *hint)
|
||||||
{
|
{
|
||||||
@@ -195,16 +195,8 @@ void SDL_SetObjectValid(void *object, SDL_ObjectType type, bool valid)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SDL_ObjectValid(void *object, SDL_ObjectType type)
|
bool SDL_FindObject(void *object, SDL_ObjectType type)
|
||||||
{
|
{
|
||||||
if (!object) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!SDL_object_validation) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
const void *object_type;
|
const void *object_type;
|
||||||
if (!SDL_FindInHashTable(SDL_objects, object, &object_type)) {
|
if (!SDL_FindInHashTable(SDL_objects, object, &object_type)) {
|
||||||
return false;
|
return false;
|
||||||
|
@@ -67,10 +67,25 @@ typedef enum
|
|||||||
|
|
||||||
extern Uint32 SDL_GetNextObjectID(void);
|
extern Uint32 SDL_GetNextObjectID(void);
|
||||||
extern void SDL_SetObjectValid(void *object, SDL_ObjectType type, bool valid);
|
extern void SDL_SetObjectValid(void *object, SDL_ObjectType type, bool valid);
|
||||||
extern bool SDL_ObjectValid(void *object, SDL_ObjectType type);
|
extern bool SDL_FindObject(void *object, SDL_ObjectType type);
|
||||||
extern int SDL_GetObjects(SDL_ObjectType type, void **objects, int count);
|
extern int SDL_GetObjects(SDL_ObjectType type, void **objects, int count);
|
||||||
extern void SDL_SetObjectsInvalid(void);
|
extern void SDL_SetObjectsInvalid(void);
|
||||||
|
|
||||||
|
extern bool SDL_object_validation;
|
||||||
|
|
||||||
|
SDL_FORCE_INLINE bool SDL_ObjectValid(void *object, SDL_ObjectType type)
|
||||||
|
{
|
||||||
|
if (!object) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!SDL_object_validation) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return SDL_FindObject(object, type);
|
||||||
|
}
|
||||||
|
|
||||||
extern const char *SDL_GetPersistentString(const char *string);
|
extern const char *SDL_GetPersistentString(const char *string);
|
||||||
|
|
||||||
extern char *SDL_CreateDeviceName(Uint16 vendor, Uint16 product, const char *vendor_name, const char *product_name, const char *default_name);
|
extern char *SDL_CreateDeviceName(Uint16 vendor, Uint16 product, const char *vendor_name, const char *product_name, const char *default_name);
|
||||||
|
Reference in New Issue
Block a user