Skip to content

Optimize class W3DMPO to remove virtual functions in release mode #1948

Description

@Caball009

class W3DMPO
{
private:
static void* getClassMemoryPool()
{
assert(0); // must replace this via W3DMPO_GLUE
return 0;
}
protected:
// we never call this; it is present to cause compile errors in descendent classes
virtual int glueEnforcer() const = 0;
public:
virtual ~W3DMPO() { /* nothing */ }
};

protected: \
virtual int glueEnforcer() const { return sizeof(this); } \

AFAICT the only reason the pure virtual function glueEnforcer exists at all is to prevent developers from being able to do this:

class Foo : public W3DMPO
{
	//W3DMPO_GLUE(Foo)
};

inline Foo foo1;

This doesn't compile because there's no glueEnforcer override, which is required.

I see no reason why this class needs to be virtual by default, and we should be able to get rid of the virtual functions in release mode for potential performance reasons.

It can probably be a void function as well.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    MinorSeverity: Minor < Major < Critical < BlockerPerformanceIs a performance concern

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions