From f2ae7796c345a56495d463e409f218cbcfd3ebe2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Foucault?= Date: Mon, 19 Mar 2018 10:47:01 +0100 Subject: GWN: Context: Use instead of We cannot have duplicates so unordered_set is better suited for this case. Removing batches is now constant time on average instead of linear. --- intern/gawain/src/gwn_vertex_array_id.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'intern/gawain') 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 #include #include -#include +#include #if TRUST_NO_ONE extern "C" { @@ -32,7 +32,7 @@ static bool thread_is_main() struct Gwn_Context { GLuint default_vao; - std::forward_list batches; // Batches that have VAOs from this context + std::unordered_set batches; // Batches that have VAOs from this context std::vector 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); } -- cgit v1.2.3