mirror of https://github.com/aria2/aria2
2009-05-10 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Use std::binary_search instead of std::find * src/DefaultPieceStorage.ccpull/1/head
parent
1d2cfd93d7
commit
52312c7a31
|
@ -1,3 +1,8 @@
|
|||
2009-05-10 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
||||
|
||||
Use std::binary_search instead of std::find
|
||||
* src/DefaultPieceStorage.cc
|
||||
|
||||
2009-05-10 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
||||
|
||||
Removed unnecessary BDE() call; leave them to implicit conversion.
|
||||
|
|
|
@ -440,14 +440,13 @@ void DefaultPieceStorage::setFileFilter(const std::deque<std::string>& filePaths
|
|||
void DefaultPieceStorage::setFileFilter(IntSequence seq)
|
||||
{
|
||||
std::deque<int32_t> fileIndexes = seq.flush();
|
||||
// TODO Is sorting necessary?
|
||||
std::sort(fileIndexes.begin(), fileIndexes.end());
|
||||
fileIndexes.erase(std::unique(fileIndexes.begin(), fileIndexes.end()), fileIndexes.end());
|
||||
std::deque<std::string> filePaths;
|
||||
const FileEntries& entries = diskAdaptor->getFileEntries();
|
||||
int32_t entriesSize = entries.size();
|
||||
for(int32_t i = 0; i < entriesSize; i++) {
|
||||
if(std::find(fileIndexes.begin(), fileIndexes.end(), i+1) != fileIndexes.end()) {
|
||||
if(std::binary_search(fileIndexes.begin(), fileIndexes.end(), i+1)) {
|
||||
logger->debug("index=%d is %s", i+1, entries[i]->getPath().c_str());
|
||||
filePaths.push_back(entries[i]->getPath());
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue