From 1ec69044fbf1c02f878ea06c5ccddeb2d9b35ca4 Mon Sep 17 00:00:00 2001 From: Charles Dang Date: Sun, 3 Jun 2018 05:20:43 +1100 Subject: [PATCH] Revert "Fixed an occasional crash resulting from multi-thread access of the image cache" This reverts commit 6d0b7c84243aba8444f5e722cd855feed3501f12. Turns out there's a better way to fix this problem without using mutexes, which have a noticeable performance hit (5.2% of the execution time of game_display::draw_invalidated() according to @jyrkive). (cherry-picked from commit b8ad791a1d8d1e76d921d4f48a6fd57aee3c134e) --- src/image.cpp | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/src/image.cpp b/src/image.cpp index 31673b6b5f35..1acbd59c8396 100644 --- a/src/image.cpp +++ b/src/image.cpp @@ -41,7 +41,6 @@ #include #include -#include #include static lg::log_domain log_display("display"); @@ -106,30 +105,23 @@ class cache_type public: cache_type() : content_() - , cache_lock_() { } cache_item& get_element(int index) { - std::lock_guard lock(cache_lock_); - - if(static_cast(index) >= content_.size()) { + if(static_cast(index) >= content_.size()) content_.resize(index + 1); - } - return content_[index]; } void flush() { - std::lock_guard lock(cache_lock_); content_.clear(); } private: std::vector> content_; - std::mutex cache_lock_; }; template