Feature #4188 » 0001-Replace-string-to-improve-Specificity-performance.patch
| src/Wt/Render/Specificity.C | ||
|---|---|---|
|
#include <cstring>
|
||
|
#include "Specificity.h"
|
||
|
using namespace Wt::Render;
|
||
|
Specificity::Specificity(bool valid)
|
||
|
: value_(" ")
|
||
|
{setA(0); setB(0); setC(0); setD(0);setValid(valid);}
|
||
|
{ std::memset(value_, 0, SPECIFICITY_LEN); setValid(valid); }
|
||
|
Specificity::Specificity(int a, int b, int c, int d)
|
||
|
: value_(" ")
|
||
|
{setA(a); setB(b); setC(c); setD(d);setValid(true);}
|
||
|
{
|
||
|
setA(a); setB(b); setC(c); setD(d); setValid(true);
|
||
|
}
|
||
|
void Specificity::setValid(bool b){value_[0] = b ? (char)1 : (char)0;}
|
||
|
void Specificity::setA (int a){value_[1] = (char)(a % 256);}
|
||
|
void Specificity::setB (int b){value_[2] = (char)(b % 256);}
|
||
|
void Specificity::setC (int c){value_[3] = (char)(c % 256);}
|
||
|
void Specificity::setD (int d){value_[4] = (char)(d % 256);}
|
||
|
void Specificity::setValid(bool b){value_[0] = b ? 1 : 0;}
|
||
|
void Specificity::setA (int a){value_[1] = a;}
|
||
|
void Specificity::setB (int b){value_[2] = b;}
|
||
|
void Specificity::setC (int c){value_[3] = c;}
|
||
|
void Specificity::setD (int d){value_[4] = d;}
|
||
|
bool Specificity::isValid() const { return value_[0] == (char)1; }
|
||
|
bool Specificity::isValid() const { return value_[0] == 1; }
|
||
|
bool Specificity::isSmallerThen(const Specificity& other) const
|
||
|
{
|
||
|
return value_ < other.value_;
|
||
|
return std::memcmp(value_, other.value_, SPECIFICITY_LEN) < 0;
|
||
|
}
|
||
|
bool Specificity::isGreaterThen(const Specificity& other) const
|
||
|
{
|
||
|
return value_ > other.value_;
|
||
|
return std::memcmp(value_, other.value_, SPECIFICITY_LEN) > 0;
|
||
|
}
|
||
|
bool Specificity::isSmallerOrEqualThen(const Specificity& other) const
|
||
| src/Wt/Render/Specificity.h | ||
|---|---|---|
|
class WT_API Specificity
|
||
|
{
|
||
|
public:
|
||
|
static const int SPECIFICITY_LEN = 5;
|
||
|
explicit Specificity(bool valid = true);
|
||
|
Specificity(int a, int b, int c, int d);
|
||
| ... | ... | |
|
#endif
|
||
|
private:
|
||
|
std::string value_;
|
||
|
char value_[SPECIFICITY_LEN];
|
||
|
};
|
||
|
}
|
||