]> git.sesse.net Git - cubemap/blobdiff - server.h
Replace map with unordered_map nearly everywhere, for speed.
[cubemap] / server.h
index da2076498f010785ae8d1a8954dc5d5920a7d83b..4ec908b039c86b24db7b8b252d27a71515a71c60 100644 (file)
--- a/server.h
+++ b/server.h
@@ -6,11 +6,11 @@
 #include <sys/epoll.h>
 #include <sys/types.h>
 #include <time.h>
-#include <map>
 #include <memory>
 #include <mutex>
 #include <queue>
 #include <string>
+#include <unordered_map>
 #include <vector>
 
 #include "tlse.h"
@@ -106,13 +106,13 @@ private:
        std::vector<std::unique_ptr<Stream>> streams;
 
        // Map from URL to index into <streams>.
-       std::map<std::string, int> stream_url_map, stream_hls_url_map;
+       std::unordered_map<std::string, int> stream_url_map, stream_hls_url_map;
 
        // Map from URL to CORS Allow-Origin header (or empty string).
-       std::map<std::string, std::string> ping_url_map;
+       std::unordered_map<std::string, std::string> ping_url_map;
 
        // Map from file descriptor to client.
-       std::map<int, Client> clients;
+       std::unordered_map<int, Client> clients;
 
        // A list of all clients, ordered by the time they connected (first element),
        // and their file descriptor (second element). It is ordered by connection time
@@ -132,7 +132,7 @@ private:
        epoll_event events[EPOLL_MAX_EVENTS];
 
        // For each TLS-enabled acceptor, our private server context for its key pair.
-       std::map<const Acceptor *, TLSContext *> tls_server_contexts;
+       std::unordered_map<const Acceptor *, TLSContext *> tls_server_contexts;
 
        // The actual worker thread.
        virtual void do_work();