Commit 601ce9ba authored by hjk's avatar hjk

CPlusPlus: Inline some Literals members

Basically all that generate at most 7 bytes. With the call being 5
and some hope of intra-caller optimization gains that shouldn't explode.

Change-Id: I4145d69d38a7956362263e9d432eb47bb58d3261
Reviewed-by: default avatarNikolai Kosjar <nikolai.kosjar@theqtcompany.com>
parent 0c42d826
......@@ -56,23 +56,7 @@ bool Literal::equalTo(const Literal *other) const
return ! std::strcmp(chars(), other->chars());
}
Literal::iterator Literal::begin() const
{ return _chars; }
Literal::iterator Literal::end() const
{ return _chars + _size; }
const char *Literal::chars() const
{ return _chars; }
char Literal::at(unsigned index) const
{ return _chars[index]; }
unsigned Literal::size() const
{ return _size; }
unsigned Literal::hashCode() const
{ return _hashCode; }
unsigned Literal::hashCode(const char *chars, unsigned size)
{
......@@ -95,23 +79,6 @@ unsigned Literal::hashCode(const char *chars, unsigned size)
}
////////////////////////////////////////////////////////////////////////////////
StringLiteral::StringLiteral(const char *chars, unsigned size)
: Literal(chars, size)
{ }
StringLiteral::~StringLiteral()
{ }
////////////////////////////////////////////////////////////////////////////////
enum {
NumericLiteralIsInt,
NumericLiteralIsFloat,
NumericLiteralIsDouble,
NumericLiteralIsLongDouble,
NumericLiteralIsLong,
NumericLiteralIsLongLong
};
NumericLiteral::NumericLiteral(const char *chars, unsigned size)
: Literal(chars, size), _flags(0)
{
......@@ -163,40 +130,7 @@ NumericLiteral::NumericLiteral(const char *chars, unsigned size)
}
}
NumericLiteral::~NumericLiteral()
{ }
bool NumericLiteral::isHex() const
{ return f._isHex; }
bool NumericLiteral::isUnsigned() const
{ return f._isUnsigned; }
bool NumericLiteral::isInt() const
{ return f._type == NumericLiteralIsInt; }
bool NumericLiteral::isFloat() const
{ return f._type == NumericLiteralIsFloat; }
bool NumericLiteral::isDouble() const
{ return f._type == NumericLiteralIsDouble; }
bool NumericLiteral::isLongDouble() const
{ return f._type == NumericLiteralIsLongDouble; }
bool NumericLiteral::isLong() const
{ return f._type == NumericLiteralIsLong; }
bool NumericLiteral::isLongLong() const
{ return f._type == NumericLiteralIsLongLong; }
////////////////////////////////////////////////////////////////////////////////
Identifier::Identifier(const char *chars, unsigned size)
: Literal(chars, size)
{ }
Identifier::~Identifier()
{ }
void Identifier::accept0(NameVisitor *visitor) const
{ visitor->visit(this); }
......
......@@ -40,14 +40,14 @@ public:
Literal(const char *chars, unsigned size);
virtual ~Literal();
iterator begin() const;
iterator end() const;
iterator begin() const { return _chars; }
iterator end() const { return _chars + _size; }
char at(unsigned index) const;
const char *chars() const;
unsigned size() const;
char at(unsigned index) const { return _chars[index]; }
const char *chars() const { return _chars; }
unsigned size() const { return _size; }
unsigned hashCode() const;
unsigned hashCode() const { return _hashCode; }
static unsigned hashCode(const char *chars, unsigned size);
bool equalTo(const Literal *other) const;
......@@ -66,25 +66,33 @@ public:
class CPLUSPLUS_EXPORT StringLiteral: public Literal
{
public:
StringLiteral(const char *chars, unsigned size);
virtual ~StringLiteral();
StringLiteral(const char *chars, unsigned size)
: Literal(chars, size)
{ }
};
class CPLUSPLUS_EXPORT NumericLiteral: public Literal
{
public:
NumericLiteral(const char *chars, unsigned size);
virtual ~NumericLiteral();
bool isInt() const;
bool isFloat() const;
bool isDouble() const;
bool isLongDouble() const;
bool isLong() const;
bool isLongLong() const;
enum {
NumericLiteralIsInt,
NumericLiteralIsFloat,
NumericLiteralIsDouble,
NumericLiteralIsLongDouble,
NumericLiteralIsLong,
NumericLiteralIsLongLong
};
bool isUnsigned() const;
bool isHex() const;
bool isInt() const { return f._type == NumericLiteralIsInt; }
bool isFloat() const { return f._type == NumericLiteralIsFloat; }
bool isDouble() const { return f._type == NumericLiteralIsDouble; }
bool isLongDouble() const { return f._type == NumericLiteralIsLongDouble; }
bool isLong() const { return f._type == NumericLiteralIsLong; }
bool isLongLong() const { return f._type == NumericLiteralIsLongLong; }
bool isUnsigned() const { return f._isUnsigned; }
bool isHex() const { return f._isHex; }
private:
struct Flags {
......@@ -101,8 +109,9 @@ private:
class CPLUSPLUS_EXPORT Identifier: public Literal, public Name
{
public:
Identifier(const char *chars, unsigned size);
virtual ~Identifier();
Identifier(const char *chars, unsigned size)
: Literal(chars, size)
{ }
virtual const Identifier *identifier() const { return this; }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment