Introduced LiteralTable::findLiteral() and Control::findIdentifier()

This commit is contained in:
Roberto Raggi
2009-09-07 13:39:46 +02:00
parent 8848be4caa
commit 6c347a12c6
3 changed files with 20 additions and 1 deletions

View File

@@ -101,7 +101,21 @@ public:
iterator end() const
{ return _literals + _literalCount + 1; }
_Literal *findOrInsertLiteral(const char *chars, unsigned size)
_Literal *findLiteral(const char *chars, unsigned size) const
{
if (_buckets) {
unsigned h = _Literal::hashCode(chars, size);
_Literal *literal = _buckets[h % _allocatedBuckets];
for (; literal; literal = static_cast<_Literal *>(literal->_next)) {
if (literal->size() == size && ! std::strncmp(literal->chars(), chars, size))
return literal;
}
}
return 0;
}
_Literal *findOrInsertLiteral(const char *chars, unsigned size)
{
if (_buckets) {
unsigned h = _Literal::hashCode(chars, size);