Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClément Foucault <foucault.clem@gmail.com>2018-03-19 12:47:01 +0300
committerClément Foucault <foucault.clem@gmail.com>2018-03-19 16:14:32 +0300
commitf2ae7796c345a56495d463e409f218cbcfd3ebe2 (patch)
tree83dda3e467505bcba5f6bbba17188fcb0cc5b63f /intern/gawain
parent8859927e6f457ec06a3889b12eb97ffd061bf26e (diff)
GWN: Context: Use <unordered_set> instead of <forward_list>
We cannot have duplicates so unordered_set is better suited for this case. Removing batches is now constant time on average instead of linear.
Diffstat (limited to 'intern/gawain')
-rw-r--r--intern/gawain/src/gwn_vertex_array_id.cpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/intern/gawain/src/gwn_vertex_array_id.cpp b/intern/gawain/src/gwn_vertex_array_id.cpp
index 90a2b42ab67..ed54562c434 100644
--- a/intern/gawain/src/gwn_vertex_array_id.cpp
+++ b/intern/gawain/src/gwn_vertex_array_id.cpp
@@ -16,7 +16,7 @@
#include <string.h>
#include <pthread.h>
#include <mutex>
-#include <forward_list>
+#include <unordered_set>
#if TRUST_NO_ONE
extern "C" {
@@ -32,7 +32,7 @@ static bool thread_is_main()
struct Gwn_Context {
GLuint default_vao;
- std::forward_list<Gwn_Batch*> batches; // Batches that have VAOs from this context
+ std::unordered_set<Gwn_Batch*> batches; // Batches that have VAOs from this context
std::vector<GLuint> orphaned_vertarray_ids;
std::mutex orphans_mutex; // todo: try spinlock instead
#if TRUST_NO_ONE
@@ -89,7 +89,7 @@ void GWN_context_discard(Gwn_Context* ctx)
while (!ctx->batches.empty())
{
// this removes the array entry
- gwn_batch_vao_cache_clear(ctx->batches.front());
+ gwn_batch_vao_cache_clear(*ctx->batches.begin());
}
glDeleteVertexArrays(1, &ctx->default_vao);
delete ctx;
@@ -161,10 +161,10 @@ void GWN_vao_free(GLuint vao_id, Gwn_Context* ctx)
void gwn_context_add_batch(Gwn_Context* ctx, Gwn_Batch* batch)
{
- ctx->batches.emplace_front(batch);
+ ctx->batches.emplace(batch);
}
void gwn_context_remove_batch(Gwn_Context* ctx, Gwn_Batch* batch)
{
- ctx->batches.remove(batch);
+ ctx->batches.erase(batch);
}