MySQL Forums
Forum List  »  Falcon

Strange code in PageWriter:pageWritten
Posted by: Vincent Van Den Berghe
Date: August 05, 2007 01:50AM

I'm reading the falcon source code for some secret project, and I can't get my head around this code in PageWriter.cpp:

void PageWriter::pageWritten(Dbb *dbb, int32 pageNumber)
{
Sync sync(&syncObject, "PageWriter::writePage");
sync.lock(Exclusive);
int slot = pageNumber % dirtyHashSize;

for (DirtyPage **ptr = pageHash + slot, *element; (element = *ptr);)
if (element->pageNumber == pageNumber && element->dbb == dbb)
{
removeElement(element);
release(element);
}
else
ptr = &element->pageCollision;

}

If the hash table can only have one DirtyPage with the required pageNumber and dbb, what's the point of searching through all collisions, after you found it?
Shouln'd this be:

void PageWriter::pageWritten(Dbb *dbb, int32 pageNumber)
{
Sync sync(&syncObject, "PageWriter::writePage");
sync.lock(Exclusive);
int slot = pageNumber % dirtyHashSize;

for (DirtyPage **ptr = pageHash + slot, *element; (element = *ptr);)
if (element->pageNumber == pageNumber && element->dbb == dbb)
{
removeElement(element);
release(element);
return;
}
else
ptr = &element->pageCollision;

}

Instead?

Options: ReplyQuote


Subject
Written By
Posted
Strange code in PageWriter:pageWritten
August 05, 2007 01:50AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.