Remove references in index iterator interface
This avoids checks.
This commit is contained in:
parent
1197afa806
commit
e8d560154a
|
@ -49,32 +49,23 @@ Index::Init(Volume* volume, const char* name, uint32 type, bool fixedKeyLength,
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
Index::GetIterator(IndexIterator* iterator)
|
Index::GetIterator(IndexIterator& iterator)
|
||||||
{
|
{
|
||||||
bool result = false;
|
AbstractIndexIterator* actualIterator = InternalGetIterator();
|
||||||
if (iterator) {
|
iterator.SetIterator(actualIterator);
|
||||||
AbstractIndexIterator* actualIterator = InternalGetIterator();
|
|
||||||
if (actualIterator) {
|
return actualIterator != NULL;
|
||||||
iterator->SetIterator(actualIterator);
|
|
||||||
result = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
Index::Find(const void* key, size_t length, IndexIterator* iterator)
|
Index::Find(const void* key, size_t length, IndexIterator& iterator)
|
||||||
{
|
{
|
||||||
bool result = false;
|
AbstractIndexIterator* actualIterator
|
||||||
if (key && iterator) {
|
= key != NULL ? InternalFind(key, length) : NULL;
|
||||||
AbstractIndexIterator* actualIterator = InternalFind(key, length);
|
iterator.SetIterator(actualIterator);
|
||||||
if (actualIterator) {
|
|
||||||
iterator->SetIterator(actualIterator);
|
return actualIterator != NULL;
|
||||||
result = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -42,9 +42,9 @@ public:
|
||||||
|
|
||||||
virtual int32 CountEntries() const = 0;
|
virtual int32 CountEntries() const = 0;
|
||||||
|
|
||||||
bool GetIterator(IndexIterator* iterator);
|
bool GetIterator(IndexIterator& iterator);
|
||||||
bool Find(const void* key, size_t length,
|
bool Find(const void* key, size_t length,
|
||||||
IndexIterator* iterator);
|
IndexIterator& iterator);
|
||||||
// sets the iterator to the first value
|
// sets the iterator to the first value
|
||||||
// >= key
|
// >= key
|
||||||
|
|
||||||
|
|
|
@ -119,7 +119,7 @@ struct Query::QueryPolicy {
|
||||||
if (iterator == NULL)
|
if (iterator == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (!index.index->GetIterator(iterator)) {
|
if (!index.index->GetIterator(*iterator)) {
|
||||||
delete iterator;
|
delete iterator;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -137,7 +137,7 @@ struct Query::QueryPolicy {
|
||||||
static status_t IndexIteratorFind(IndexIterator* indexIterator,
|
static status_t IndexIteratorFind(IndexIterator* indexIterator,
|
||||||
const void* value, size_t size)
|
const void* value, size_t size)
|
||||||
{
|
{
|
||||||
if (!indexIterator->index->Find(value, size, indexIterator))
|
if (!indexIterator->index->Find(value, size, *indexIterator))
|
||||||
return B_ENTRY_NOT_FOUND;
|
return B_ENTRY_NOT_FOUND;
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
|
|
Loading…
Reference in New Issue