Drake's trivially copyable optimop
This commit is contained in:
@@ -57,10 +57,10 @@ public:
|
||||
LLUUID();
|
||||
explicit LLUUID(const char *in_string); // Convert from string.
|
||||
explicit LLUUID(const std::string& in_string); // Convert from string.
|
||||
LLUUID(const LLUUID &in);
|
||||
LLUUID &operator=(const LLUUID &rhs);
|
||||
LLUUID(const LLUUID &in) = default;
|
||||
LLUUID &operator=(const LLUUID &rhs) = default;
|
||||
|
||||
~LLUUID();
|
||||
~LLUUID() = default;
|
||||
|
||||
//
|
||||
// MANIPULATORS
|
||||
@@ -193,24 +193,6 @@ inline BOOL LLUUID::isNull() const
|
||||
return !memcmp(mData, null.mData, sizeof(mData)); // <alchemy/>
|
||||
}
|
||||
|
||||
// Copy constructor
|
||||
inline LLUUID::LLUUID(const LLUUID& rhs)
|
||||
{
|
||||
memcpy(mData, rhs.mData, sizeof(mData)); // <alchemy/>
|
||||
}
|
||||
|
||||
inline LLUUID::~LLUUID()
|
||||
{
|
||||
}
|
||||
|
||||
// Assignment
|
||||
inline LLUUID& LLUUID::operator=(const LLUUID& rhs)
|
||||
{
|
||||
memcpy(mData, rhs.mData, sizeof(mData)); // <alchemy/>
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
inline LLUUID::LLUUID(const char *in_string)
|
||||
{
|
||||
if (!in_string || in_string[0] == 0)
|
||||
@@ -289,6 +271,8 @@ inline U32 LLUUID::getCRC32() const
|
||||
// </alchemy>
|
||||
}
|
||||
|
||||
static_assert(std::is_trivially_copyable<LLUUID>{}, "LLUUID must be a trivially copyable type");
|
||||
|
||||
typedef std::vector<LLUUID> uuid_vec_t;
|
||||
typedef boost::unordered_set<LLUUID> uuid_set_t;
|
||||
|
||||
|
||||
@@ -127,4 +127,6 @@ public:
|
||||
inline bool isOkRotation() const;
|
||||
} LL_ALIGN_POSTFIX(16);
|
||||
|
||||
static_assert(std::is_trivially_copyable<LLMatrix3a>{}, "LLMatrix3a must be a trivially copyable type");
|
||||
static_assert(std::is_trivially_copyable<LLRotation>{}, "LLRotation must be a trivially copyable type");
|
||||
#endif
|
||||
|
||||
@@ -708,4 +708,6 @@ inline std::ostream& operator<<(std::ostream& s, const LLMatrix4a& m)
|
||||
}
|
||||
|
||||
void matMulBoundBox(const LLMatrix4a &a, const LLVector4a *in_extents, LLVector4a *out_extents);
|
||||
|
||||
static_assert(std::is_trivially_copyable<LLMatrix4a>{}, "LLMatrix4a must be a trivially copyable type");
|
||||
#endif
|
||||
|
||||
@@ -191,6 +191,8 @@ inline void LLQuaternion::setValue(const LLSD& sd)
|
||||
mQ[3] = sd[3].asReal();
|
||||
}
|
||||
|
||||
static_assert(std::is_trivially_copyable<LLQuaternion>{}, "LLQuaternion must be a trivially copyable type");
|
||||
|
||||
// checker
|
||||
inline BOOL LLQuaternion::isFinite() const
|
||||
{
|
||||
|
||||
@@ -105,4 +105,6 @@ protected:
|
||||
|
||||
} LL_ALIGN_POSTFIX(16);
|
||||
|
||||
static_assert(std::is_trivially_copyable<LLQuaternion2>{}, "LLQuaternion2 must be a trivially copyable type");
|
||||
|
||||
#endif
|
||||
|
||||
@@ -121,4 +121,7 @@ private:
|
||||
LLQuad mQ;
|
||||
};
|
||||
|
||||
static_assert(std::is_trivially_copyable<LLBool32>{}, "LLBool32 must be a trivially copyable type");
|
||||
static_assert(std::is_trivially_copyable<LLSimdScalar>{}, "LLSimdScalar must be a trivially copyable type");
|
||||
|
||||
#endif //LL_SIMD_TYPES_H
|
||||
|
||||
@@ -96,12 +96,12 @@ public:
|
||||
{ //DO NOT INITIALIZE -- The overhead is completely unnecessary
|
||||
ll_assert_aligned(this,16);
|
||||
}
|
||||
|
||||
|
||||
LLVector4a(F32 x, F32 y, F32 z, F32 w = 0.f)
|
||||
{
|
||||
set(x,y,z,w);
|
||||
set(x, y, z, w);
|
||||
}
|
||||
|
||||
|
||||
LLVector4a(F32 x)
|
||||
{
|
||||
splat(x);
|
||||
@@ -320,9 +320,13 @@ public:
|
||||
////////////////////////////////////
|
||||
|
||||
// Do NOT add aditional operators without consulting someone with SSE experience
|
||||
inline const LLVector4a& operator= ( const LLVector4a& rhs );
|
||||
//inline const LLVector4a& operator= ( const LLVector4a& rhs );
|
||||
//{
|
||||
// mQ = rhs.mQ;
|
||||
// return *this;
|
||||
//}
|
||||
|
||||
inline const LLVector4a& operator= ( const LLQuad& rhs );
|
||||
inline const LLVector4a& operator= (const LLQuad& rhs);
|
||||
|
||||
inline operator LLQuad() const;
|
||||
|
||||
@@ -341,4 +345,6 @@ inline std::ostream& operator<<(std::ostream& s, const LLVector4a& v)
|
||||
s << "(" << v[0] << ", " << v[1] << ", " << v[2] << ", " << v[3] << ")";
|
||||
return s;
|
||||
}
|
||||
|
||||
static_assert(std::is_trivially_copyable<LLVector4a>{}, "LLVector4a must be a trivially copyable type");
|
||||
#endif
|
||||
|
||||
@@ -605,13 +605,7 @@ inline bool LLVector4a::equals3(const LLVector4a& rhs, F32 tolerance ) const
|
||||
////////////////////////////////////
|
||||
|
||||
// Do NOT add aditional operators without consulting someone with SSE experience
|
||||
inline const LLVector4a& LLVector4a::operator= ( const LLVector4a& rhs )
|
||||
{
|
||||
mQ = rhs.mQ;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline const LLVector4a& LLVector4a::operator= ( const LLQuad& rhs )
|
||||
inline const LLVector4a& LLVector4a::operator= (const LLQuad& rhs)
|
||||
{
|
||||
mQ = rhs;
|
||||
return *this;
|
||||
|
||||
@@ -144,6 +144,8 @@ class LLMatrix3
|
||||
friend std::ostream& operator<<(std::ostream& s, const LLMatrix3 &a); // Stream a
|
||||
};
|
||||
|
||||
static_assert(std::is_trivially_copyable<LLMatrix3>{}, "LLMatrix3 must be a trivially copyable type");
|
||||
|
||||
inline LLMatrix3::LLMatrix3(void)
|
||||
{
|
||||
mMatrix[0][0] = 1.f;
|
||||
|
||||
@@ -152,10 +152,6 @@ LLMatrix4::LLMatrix4(const F32 roll, const F32 pitch, const F32 yaw)
|
||||
mMatrix[3][3] = 1.f;
|
||||
}
|
||||
|
||||
LLMatrix4::~LLMatrix4(void)
|
||||
{
|
||||
}
|
||||
|
||||
// Clear and Assignment Functions
|
||||
|
||||
const LLMatrix4& LLMatrix4::setZero()
|
||||
|
||||
@@ -117,7 +117,7 @@ public:
|
||||
const LLVector4 &pos); // Initializes Matrix with Euler angles
|
||||
LLMatrix4(const F32 roll, const F32 pitch, const F32 yaw); // Initializes Matrix with Euler angles
|
||||
|
||||
~LLMatrix4(void); // Destructor
|
||||
~LLMatrix4() = default; // Destructor
|
||||
|
||||
LLSD getValue() const;
|
||||
void setValue(const LLSD&);
|
||||
@@ -246,6 +246,8 @@ public:
|
||||
friend std::ostream& operator<<(std::ostream& s, const LLMatrix4 &a); // Stream a
|
||||
};
|
||||
|
||||
static_assert(std::is_trivially_copyable<LLMatrix4>{}, "LLMatrix4 must be a trivially copyable type");
|
||||
|
||||
inline const LLMatrix4& LLMatrix4::setIdentity()
|
||||
{
|
||||
mMatrix[0][0] = 1.f;
|
||||
|
||||
@@ -110,6 +110,7 @@ class LLVector2
|
||||
friend std::ostream& operator<<(std::ostream& s, const LLVector2 &a); // Stream a
|
||||
};
|
||||
|
||||
static_assert(std::is_trivially_copyable<LLVector2>{}, "LLVector2 must be a trivially copyable type");
|
||||
|
||||
// Non-member functions
|
||||
|
||||
|
||||
@@ -140,6 +140,8 @@ public:
|
||||
inline void exp(); // Do an exponential on the color
|
||||
};
|
||||
|
||||
static_assert(std::is_trivially_copyable<LLColor3>{}, "LLColor3 must be a trivially copyable type");
|
||||
|
||||
LLColor3 lerp(const LLColor3 &a, const LLColor3 &b, F32 u);
|
||||
|
||||
|
||||
|
||||
@@ -130,6 +130,8 @@ class LLVector3d
|
||||
|
||||
};
|
||||
|
||||
static_assert(std::is_trivially_copyable<LLVector3d>{}, "LLVector3d must be a trivially copyable type");
|
||||
|
||||
typedef LLVector3d LLGlobalVec;
|
||||
|
||||
inline const LLVector3d &LLVector3d::set(const LLVector3 &vec)
|
||||
|
||||
@@ -149,6 +149,8 @@ class LLVector3
|
||||
static BOOL parseVector3(const std::string& buf, LLVector3* value);
|
||||
};
|
||||
|
||||
static_assert(std::is_trivially_copyable<LLVector3>{}, "LLVector3 must be a trivially copyable type");
|
||||
|
||||
typedef LLVector3 LLSimLocalVec;
|
||||
|
||||
// Non-member functions
|
||||
|
||||
@@ -222,6 +222,7 @@ class LLColor4
|
||||
inline void clamp();
|
||||
};
|
||||
|
||||
static_assert(std::is_trivially_copyable<LLColor4>{}, "LLColor4 must be a trivially copyable type");
|
||||
|
||||
// Non-member functions
|
||||
F32 distVec(const LLColor4 &a, const LLColor4 &b); // Returns distance between a and b
|
||||
|
||||
@@ -139,6 +139,7 @@ public:
|
||||
static LLColor4U blue;
|
||||
};
|
||||
|
||||
static_assert(std::is_trivially_copyable<LLColor4U>{}, "LLColor4U must be a trivially copyable type");
|
||||
|
||||
// Non-member functions
|
||||
F32 distVec(const LLColor4U &a, const LLColor4U &b); // Returns distance between a and b
|
||||
|
||||
@@ -137,6 +137,8 @@ class LLVector4
|
||||
friend LLVector4 operator-(const LLVector4 &a); // Return vector -a
|
||||
};
|
||||
|
||||
static_assert(std::is_trivially_copyable<LLVector4>{}, "LLVector4 must be a trivially copyable type");
|
||||
|
||||
// Non-member functions
|
||||
F32 angle_between(const LLVector4 &a, const LLVector4 &b); // Returns angle (radians) between a and b
|
||||
BOOL are_parallel(const LLVector4 &a, const LLVector4 &b, F32 epsilon=F_APPROXIMATELY_ZERO); // Returns TRUE if a and b are very close to parallel
|
||||
|
||||
@@ -56,15 +56,6 @@ LLMaterialID::LLMaterialID(const void* pMemory)
|
||||
set(pMemory);
|
||||
}
|
||||
|
||||
LLMaterialID::LLMaterialID(const LLMaterialID& pOtherMaterialID)
|
||||
{
|
||||
copyFromOtherMaterialID(pOtherMaterialID);
|
||||
}
|
||||
|
||||
LLMaterialID::~LLMaterialID()
|
||||
{
|
||||
}
|
||||
|
||||
bool LLMaterialID::operator == (const LLMaterialID& pOtherMaterialID) const
|
||||
{
|
||||
return (compareToOtherMaterialID(pOtherMaterialID) == 0);
|
||||
@@ -95,12 +86,6 @@ bool LLMaterialID::operator >= (const LLMaterialID& pOtherMaterialID) const
|
||||
return (compareToOtherMaterialID(pOtherMaterialID) >= 0);
|
||||
}
|
||||
|
||||
LLMaterialID& LLMaterialID::operator = (const LLMaterialID& pOtherMaterialID)
|
||||
{
|
||||
copyFromOtherMaterialID(pOtherMaterialID);
|
||||
return (*this);
|
||||
}
|
||||
|
||||
bool LLMaterialID::isNull() const
|
||||
{
|
||||
return (compareToOtherMaterialID(LLMaterialID::null) == 0);
|
||||
@@ -116,12 +101,12 @@ void LLMaterialID::set(const void* pMemory)
|
||||
llassert(pMemory != NULL);
|
||||
|
||||
// assumes that the required size of memory is available
|
||||
memcpy(mID, pMemory, MATERIAL_ID_SIZE * sizeof(U8));
|
||||
memcpy(mID, pMemory, sizeof(mID));
|
||||
}
|
||||
|
||||
void LLMaterialID::clear()
|
||||
{
|
||||
memset(mID, 0, MATERIAL_ID_SIZE * sizeof(U8));
|
||||
memset(mID, 0, sizeof(mID));
|
||||
}
|
||||
|
||||
LLSD LLMaterialID::asLLSD() const
|
||||
@@ -156,18 +141,12 @@ std::ostream& operator<<(std::ostream& s, const LLMaterialID &material_id)
|
||||
return s;
|
||||
}
|
||||
|
||||
|
||||
void LLMaterialID::parseFromBinary (const LLSD::Binary& pMaterialID)
|
||||
{
|
||||
llassert(pMaterialID.size() == (MATERIAL_ID_SIZE * sizeof(U8)));
|
||||
memcpy(mID, &pMaterialID[0], MATERIAL_ID_SIZE * sizeof(U8));
|
||||
}
|
||||
|
||||
void LLMaterialID::copyFromOtherMaterialID(const LLMaterialID& pOtherMaterialID)
|
||||
{
|
||||
memcpy(mID, pOtherMaterialID.get(), MATERIAL_ID_SIZE * sizeof(U8));
|
||||
}
|
||||
|
||||
int LLMaterialID::compareToOtherMaterialID(const LLMaterialID& pOtherMaterialID) const
|
||||
{
|
||||
int retVal = 0;
|
||||
|
||||
@@ -39,8 +39,8 @@ public:
|
||||
LLMaterialID(const LLSD& pMaterialID);
|
||||
LLMaterialID(const LLSD::Binary& pMaterialID);
|
||||
LLMaterialID(const void* pMemory);
|
||||
LLMaterialID(const LLMaterialID& pOtherMaterialID);
|
||||
~LLMaterialID();
|
||||
LLMaterialID(const LLMaterialID& pOtherMaterialID) = default;
|
||||
~LLMaterialID() = default;
|
||||
|
||||
bool operator == (const LLMaterialID& pOtherMaterialID) const;
|
||||
bool operator != (const LLMaterialID& pOtherMaterialID) const;
|
||||
@@ -50,7 +50,7 @@ public:
|
||||
bool operator > (const LLMaterialID& pOtherMaterialID) const;
|
||||
bool operator >= (const LLMaterialID& pOtherMaterialID) const;
|
||||
|
||||
LLMaterialID& operator = (const LLMaterialID& pOtherMaterialID);
|
||||
LLMaterialID& operator = (const LLMaterialID& pOtherMaterialID) = default;
|
||||
|
||||
bool isNull() const;
|
||||
|
||||
@@ -67,11 +67,13 @@ public:
|
||||
|
||||
private:
|
||||
void parseFromBinary(const LLSD::Binary& pMaterialID);
|
||||
void copyFromOtherMaterialID(const LLMaterialID& pOtherMaterialID);
|
||||
int compareToOtherMaterialID(const LLMaterialID& pOtherMaterialID) const;
|
||||
|
||||
U8 mID[MATERIAL_ID_SIZE];
|
||||
} ;
|
||||
|
||||
static_assert(sizeof(LLMaterialID) == MATERIAL_ID_SIZE, "LLMaterialID must be sizeof(mID)");
|
||||
static_assert(std::is_trivially_copyable<LLMaterialID>{}, "LLMaterialID must be a trivially copyable type");
|
||||
|
||||
#endif // LL_LLMATERIALID_H
|
||||
|
||||
|
||||
Reference in New Issue
Block a user