Use flat_map in ReceiveStatisticsImpl

std::unordered_map represents ~0.57% CPU in a loaded media server,
which is expected to be reduced by using flat_map and its increased
cache locality compared to std::unordered_map, which use quite a few
allocations and indirections.

The number of SSRCs tracked by this class is expected to be low and
infrequently updated, but as GetOrCreateStatistician is called for every
incoming RTP packet, lookups are frequent.

Bug: webrtc:12689
Change-Id: I9a2c3798dcc7822f518e8f2624e78fceacd12d27
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/225202
Reviewed-by: Danil Chapovalov <danilchap@webrtc.org>
Commit-Queue: Victor Boivie <boivie@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#34430}
diff --git a/modules/rtp_rtcp/BUILD.gn b/modules/rtp_rtcp/BUILD.gn
index f056df3..3e25d18 100644
--- a/modules/rtp_rtcp/BUILD.gn
+++ b/modules/rtp_rtcp/BUILD.gn
@@ -303,6 +303,7 @@
     "../../rtc_base/task_utils:repeating_task",
     "../../rtc_base/task_utils:to_queued_task",
     "../../rtc_base/time:timestamp_extrapolator",
+    "../../rtc_base/containers:flat_map",
     "../../system_wrappers",
     "../../system_wrappers:metrics",
     "../remote_bitrate_estimator",
diff --git a/modules/rtp_rtcp/source/receive_statistics_impl.h b/modules/rtp_rtcp/source/receive_statistics_impl.h
index 44f5144..1a70fe4 100644
--- a/modules/rtp_rtcp/source/receive_statistics_impl.h
+++ b/modules/rtp_rtcp/source/receive_statistics_impl.h
@@ -14,7 +14,6 @@
 #include <algorithm>
 #include <functional>
 #include <memory>
-#include <unordered_map>
 #include <utility>
 #include <vector>
 
@@ -22,6 +21,7 @@
 #include "modules/include/module_common_types_public.h"
 #include "modules/rtp_rtcp/include/receive_statistics.h"
 #include "modules/rtp_rtcp/source/rtcp_packet/report_block.h"
+#include "rtc_base/containers/flat_map.h"
 #include "rtc_base/rate_statistics.h"
 #include "rtc_base/synchronization/mutex.h"
 #include "rtc_base/thread_annotations.h"
@@ -195,8 +195,7 @@
   size_t last_returned_ssrc_idx_;
   std::vector<uint32_t> all_ssrcs_;
   int max_reordering_threshold_;
-  std::unordered_map<uint32_t /*ssrc*/,
-                     std::unique_ptr<StreamStatisticianImplInterface>>
+  flat_map<uint32_t /*ssrc*/, std::unique_ptr<StreamStatisticianImplInterface>>
       statisticians_;
 };