Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Commit

Permalink
[core] Switch unordered_map to map
Browse files Browse the repository at this point in the history
Change container types where number of elements expected
to be rather small. For instance, number of offline packs
or sql statements.
  • Loading branch information
alexshalamov committed Feb 6, 2020
1 parent c9b30f4 commit 2fbd46f
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 10 deletions.
6 changes: 3 additions & 3 deletions platform/default/include/mbgl/storage/offline_database.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
#include <mbgl/util/mapbox.hpp>
#include <mbgl/util/expected.hpp>

#include <unordered_map>
#include <list>
#include <map>
#include <memory>
#include <string>
#include <list>

namespace mapbox {
namespace sqlite {
Expand Down Expand Up @@ -140,7 +140,7 @@ class OfflineDatabase : private util::noncopyable {

std::string path;
std::unique_ptr<mapbox::sqlite::Database> db;
std::unordered_map<const char *, const std::unique_ptr<mapbox::sqlite::Statement>> statements;
std::map<const char*, const std::unique_ptr<mapbox::sqlite::Statement>> statements;

template <class T>
T getPragma(const char *);
Expand Down
2 changes: 1 addition & 1 deletion platform/default/include/mbgl/storage/offline_download.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class OfflineDownload {
std::unique_ptr<OfflineRegionObserver> observer;

std::list<std::unique_ptr<AsyncRequest>> requests;
std::unordered_set<std::string> requiredSourceURLs;
std::set<std::string> requiredSourceURLs;
std::deque<Resource> resourcesRemaining;
std::list<Resource> resourcesToBeMarkedAsUsed;
std::list<std::tuple<Resource, Response>> buffer;
Expand Down
4 changes: 3 additions & 1 deletion platform/default/src/mbgl/storage/database_file_source.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
#include <mbgl/util/platform.hpp>
#include <mbgl/util/thread.hpp>

#include <map>

namespace mbgl {

// For testing use only
Expand Down Expand Up @@ -143,7 +145,7 @@ class DatabaseFileSourceThread {
}

std::unique_ptr<OfflineDatabase> db;
std::unordered_map<int64_t, std::unique_ptr<OfflineDownload>> downloads;
std::map<int64_t, std::unique_ptr<OfflineDownload>> downloads;
std::shared_ptr<FileSource> onlineFileSource;
};

Expand Down
3 changes: 2 additions & 1 deletion platform/default/src/mbgl/storage/main_resource_loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <mbgl/util/thread.hpp>

#include <cassert>
#include <map>

namespace mbgl {

Expand Down Expand Up @@ -117,7 +118,7 @@ class MainResourceLoaderThread {
const std::shared_ptr<FileSource> databaseFileSource;
const std::shared_ptr<FileSource> localFileSource;
const std::shared_ptr<FileSource> onlineFileSource;
std::unordered_map<AsyncRequest*, std::unique_ptr<AsyncRequest>> tasks;
std::map<AsyncRequest*, std::unique_ptr<AsyncRequest>> tasks;
};

class MainResourceLoader::Impl {
Expand Down
6 changes: 2 additions & 4 deletions platform/default/src/mbgl/storage/online_file_source.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
#include <cassert>
#include <list>
#include <map>
#include <unordered_map>
#include <unordered_set>

namespace mbgl {

Expand Down Expand Up @@ -277,11 +275,11 @@ class OnlineFileSourceThread {
* Requests in any state are in `allRequests`. Requests in the pending state are in
* `pendingRequests`. Requests in the active state are in `activeRequests`.
*/
std::unordered_set<OnlineFileRequest*> allRequests;
std::set<OnlineFileRequest*> allRequests;

PendingRequests pendingRequests;

std::unordered_set<OnlineFileRequest*> activeRequests;
std::set<OnlineFileRequest*> activeRequests;

bool online = true;
uint32_t maximumConcurrentRequests;
Expand Down

0 comments on commit 2fbd46f

Please sign in to comment.