Perf: Use vector to replace list for object cache

pull/2204/head
winlin 4 years ago
parent f2d9eb345c
commit 6656330d2a

@ -31,6 +31,7 @@
#include <string> #include <string>
#include <list> #include <list>
#include <vector>
class SrsRtpPacket2; class SrsRtpPacket2;
@ -360,7 +361,7 @@ class SrsRtpObjectCacheManager
{ {
private: private:
bool enabled_; bool enabled_;
std::list<T*> cache_objs_; std::vector<T*> cache_objs_;
size_t capacity_; size_t capacity_;
size_t object_size_; size_t object_size_;
public: public:
@ -370,7 +371,7 @@ public:
object_size_ = size_of_object; object_size_ = size_of_object;
} }
virtual ~SrsRtpObjectCacheManager() { virtual ~SrsRtpObjectCacheManager() {
typedef typename std::list<T*>::iterator iterator; typedef typename std::vector<T*>::iterator iterator;
for (iterator it = cache_objs_.begin(); it != cache_objs_.end(); ++it) { for (iterator it = cache_objs_.begin(); it != cache_objs_.end(); ++it) {
T* obj = *it; T* obj = *it;
srs_freep(obj); srs_freep(obj);

Loading…
Cancel
Save