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

Function ComparePartFiles

src/DownloadQueue.cpp:992–1014  ·  view source on GitHub ↗

Comparison function needed by sort. Returns true if file1 precedes file2

Source from the content-addressed store, hash-verified

990
991// Comparison function needed by sort. Returns true if file1 precedes file2
992static bool ComparePartFiles(const CPartFile* file1, const CPartFile* file2) {
993 if (file1->GetDownPriority() != file2->GetDownPriority()) {
994 // To place high-priority files before low priority files we have to
995 // invert this test, since PR_LOW is lower than PR_HIGH, and since
996 // placing a PR_LOW file before a PR_HIGH file would mean that
997 // the PR_LOW file gets sources before the PR_HIGH file ...
998 return (file1->GetDownPriority() > file2->GetDownPriority());
999 } else {
1000 int sourcesA = file1->GetSourceCount();
1001 int sourcesB = file2->GetSourceCount();
1002
1003 int notSourcesA = file1->GetNotCurrentSourcesCount();
1004 int notSourcesB = file2->GetNotCurrentSourcesCount();
1005
1006 int cmp = CmpAny( sourcesA - notSourcesA, sourcesB - notSourcesB );
1007
1008 if ( cmp == 0 ) {
1009 cmp = CmpAny( notSourcesA, notSourcesB );
1010 }
1011
1012 return cmp < 0;
1013 }
1014}
1015
1016
1017void CDownloadQueue::DoSortByPriority()

Callers

nothing calls this directly

Calls 4

GetDownPriorityMethod · 0.80
CmpAnyFunction · 0.70
GetSourceCountMethod · 0.45

Tested by

no test coverage detected