瀏覽代碼

sokol_gfx.h: remove _sg.commit_listeners.upper shrinking, isn't actually all that useful

Andre Weissflog 2 年之前
父節點
當前提交
9c53493f25
共有 2 個文件被更改,包括 3 次插入7 次删除
  1. 0 4
      sokol_gfx.h
  2. 3 3
      tests/functional/sokol_gfx_test.c

+ 0 - 4
sokol_gfx.h

@@ -15365,10 +15365,6 @@ _SOKOL_PRIVATE bool _sg_remove_commit_listener(const sg_commit_listener* listene
         if ((slot->func == listener->func) && (slot->user_data == listener->user_data)) {
             slot->func = 0;
             slot->user_data = 0;
-            if (i == (_sg.commit_listeners.upper - 1)) {
-                SOKOL_ASSERT(_sg.commit_listeners.upper > 0);
-                _sg.commit_listeners.upper -= 1;
-            }
             // NOTE: since _sg_add_commit_listener() already catches duplicates,
             // we don't need to worry about them here
             return true;

+ 3 - 3
tests/functional/sokol_gfx_test.c

@@ -910,7 +910,7 @@ UTEST(sokol_gfx, commit_listener_add_remove_add) {
     T(sg_add_commit_listener(listener));
     T(_sg.commit_listeners.upper == 1);
     T(sg_remove_commit_listener(listener));
-    T(_sg.commit_listeners.upper == 0);
+    T(_sg.commit_listeners.upper == 1);
     sg_commit();
     T(0 == commit_listener.num_called);
     T(sg_add_commit_listener(listener));
@@ -974,14 +974,14 @@ UTEST(sokol_gfx, commit_listener_multi_add_remove) {
     commit_listener.num_called = 0;
     // removing the second listener will decrement the upper bound
     T(sg_remove_commit_listener(l1));
-    T(_sg.commit_listeners.upper == 1);
+    T(_sg.commit_listeners.upper == 2);
     sg_commit();
     T(commit_listener.num_called == 1);
     T(commit_listener.userdata == 23);
     commit_listener.num_called = 0;
     // and finally remove the first listener too
     T(sg_remove_commit_listener(l0));
-    T(_sg.commit_listeners.upper == 0);
+    T(_sg.commit_listeners.upper == 2);
     sg_commit();
     T(commit_listener.num_called == 0);
     // removing the same listener twice just returns false