From 2760ed2e8ae26c78bfc57712dca048274f4e37fa Mon Sep 17 00:00:00 2001 From: TheAssassin Date: Fri, 1 Jun 2018 15:15:40 +0200 Subject: [PATCH] Improve duplicates check efficiency Use binary search instead of linear search. --- src/core/appdir.cpp | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/src/core/appdir.cpp b/src/core/appdir.cpp index 5271f7c..04555fd 100644 --- a/src/core/appdir.cpp +++ b/src/core/appdir.cpp @@ -108,17 +108,7 @@ namespace linuxdeploy { } bool checkDuplicate(const bf::path& path) { - // FIXME: use more efficient search (e.g., binary search) - // a linear search is not _really_ efficient - //return std::binary_search(copyOperations.begin(), copyOperations.end(), path); - for (const auto& pair : copyOperations) { - if (pair.first == path) { - ldLog() << LD_DEBUG << "Duplicate:" << pair.first << std::endl; - return true; - } - } - - return false; + return copyOperations.find(path) != copyOperations.end(); } // execute deferred copy operations registered with the deploy* functions