diff options
author | Marco Bubke <marco.bubke@qt.io> | 2019-08-06 14:35:06 +0200 |
---|---|---|
committer | Marco Bubke <marco.bubke@qt.io> | 2019-08-27 11:51:39 +0000 |
commit | d9b7092a874a93b03e37a36718f76f3a1ab8da9f (patch) | |
tree | d3f30d4e37c765002673593c832fff2f47f463df /src/libs/clangsupport/stringcache.h | |
parent | f9fb4508d4b73b59b7a7a3c74c009cdccb24d21c (diff) | |
download | qt-creator-d9b7092a874a93b03e37a36718f76f3a1ab8da9f.tar.gz |
Clang: Use no mutex in copyable file path cache
We use it in worker threads and there should be no access from different
threads.
Change-Id: I62874761221c45f88ce4d7cfda4fbda4bc446cac
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
Diffstat (limited to 'src/libs/clangsupport/stringcache.h')
-rw-r--r-- | src/libs/clangsupport/stringcache.h | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/src/libs/clangsupport/stringcache.h b/src/libs/clangsupport/stringcache.h index 5d416a46c4..5a1ea8fd35 100644 --- a/src/libs/clangsupport/stringcache.h +++ b/src/libs/clangsupport/stringcache.h @@ -101,6 +101,9 @@ template<typename StringType, typename CacheEntry = StringCacheEntry<StringType, StringViewType, IndexType>> class StringCache { + template<typename T, typename V, typename I, typename M, typename C, C c, typename CE> + friend class StringCache; + public: using CacheEntries = std::vector<CacheEntry>; using const_iterator = typename CacheEntries::const_iterator; @@ -116,12 +119,26 @@ public: : m_strings(other.m_strings) , m_indices(other.m_indices) {} - StringCache &operator=(const StringCache &other) + + template<typename Cache> + Cache clone() { - if (*this != other) { - m_strings = other.m_strings; - m_indices = other.m_indices; - } + Cache cache; + cache.m_strings = m_strings; + cache.m_indices = m_indices; + + return cache; + } + + StringCache(StringCache &&other) + : m_strings(std::move(other.m_strings)) + , m_indices(std::move(other.m_indices)) + {} + + StringCache &operator=(StringCache &&other) + { + m_strings = std::move(other.m_strings); + m_indices = std::move(other.m_indices); return *this; } |