mirror of
https://github.com/love2d/love.git
synced 2026-08-16 16:20:42 +02:00
Minor performance tweaks for love::Type
On my system these tweaks restore performance to "enum" levels --HG-- branch : dynamiccore2
This commit is contained in:
+21
-8
@@ -38,17 +38,30 @@ public:
|
||||
Type(const char *name, Type *parent);
|
||||
Type(const Type&) = delete;
|
||||
|
||||
void init();
|
||||
uint32 getId();
|
||||
bool isa(const uint32 &other);
|
||||
bool isa(Type &other);
|
||||
const char *getName() const;
|
||||
|
||||
static Type *byName(const char *name);
|
||||
|
||||
private:
|
||||
static uint32 nextId;
|
||||
void init();
|
||||
uint32 getId();
|
||||
const char *getName() const;
|
||||
|
||||
bool isa(const uint32 &other)
|
||||
{
|
||||
if (!inited)
|
||||
init();
|
||||
return bits[other];
|
||||
}
|
||||
|
||||
bool isa(Type &other)
|
||||
{
|
||||
if (!inited)
|
||||
init();
|
||||
// Note that if this type implements the other
|
||||
// calling init above will also have inited
|
||||
// the other.
|
||||
return bits[other.id];
|
||||
}
|
||||
|
||||
private:
|
||||
const char * const name;
|
||||
Type * const parent;
|
||||
uint32 id;
|
||||
|
||||
Reference in New Issue
Block a user