MCPcopy Create free account
hub / github.com/amule-project/amule / PrepareIndex

Method PrepareIndex

src/KnownFileList.cpp:589–606  ·  view source on GitHub ↗

Make a (size, mtime) index to speed up FindKnownFile. Size + mtime modulo 2^32 is enough here — same precision the rest of the file uses for FindKnownFile's inputs and KnownFileMatches' comparisons.

Source from the content-addressed store, hash-verified

587// modulo 2^32 is enough here — same precision the rest of the file
588// uses for FindKnownFile's inputs and KnownFileMatches' comparisons.
589void CKnownFileList::PrepareIndex()
590{
591 ReleaseIndex();
592 m_knownSizeMap = new KnownFileSizeMap;
593 for (CKnownFileMap::const_iterator it = m_knownFileMap.begin(); it != m_knownFileMap.end(); ++it) {
594 m_knownSizeMap->insert(std::make_pair(
595 std::make_pair((uint32) it->second->GetFileSize(),
596 (uint32) it->second->GetLastChangeDatetime()),
597 it->second));
598 }
599 m_duplicateSizeMap = new KnownFileSizeMap;
600 for (KnownFileList::const_iterator it = m_duplicateFileList.begin(); it != m_duplicateFileList.end(); ++it) {
601 m_duplicateSizeMap->insert(std::make_pair(
602 std::make_pair((uint32) (*it)->GetFileSize(),
603 (uint32) (*it)->GetLastChangeDatetime()),
604 *it));
605 }
606}
607
608
609void CKnownFileList::ReleaseIndex()

Callers 1

FindSharedFilesMethod · 0.80

Calls 5

insertMethod · 0.80
GetLastChangeDatetimeMethod · 0.80
beginMethod · 0.45
endMethod · 0.45
GetFileSizeMethod · 0.45

Tested by

no test coverage detected