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.
| 587 | // modulo 2^32 is enough here — same precision the rest of the file |
| 588 | // uses for FindKnownFile's inputs and KnownFileMatches' comparisons. |
| 589 | void 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 | |
| 609 | void CKnownFileList::ReleaseIndex() |
no test coverage detected