diff --git a/.gitignore b/.gitignore index 5e0143c..6c29eaa 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,6 @@ test/compile_test_32 test/external_allocator_test test/external_allocator_test_32 .gdb_history +__test__*__ +*.exe +.directory diff --git a/src/containers/dynamicarray.d b/src/containers/dynamicarray.d index be08f33..e911cd4 100644 --- a/src/containers/dynamicarray.d +++ b/src/containers/dynamicarray.d @@ -59,7 +59,7 @@ struct DynamicArray(T, Allocator = Mallocator, bool supportGC = shouldAddGCRange else typeid(T).destroy(&item); } - static if (shouldAddGCRange!T) + static if (useGC) { import core.memory : GC; GC.removeRange(arr.ptr); diff --git a/src/containers/ttree.d b/src/containers/ttree.d index b7f0ad3..811b066 100644 --- a/src/containers/ttree.d +++ b/src/containers/ttree.d @@ -395,6 +395,8 @@ private: enum RangeType : ubyte { all, lower, equal, upper } + enum bool useGC = supportGC && shouldAddGCRange!T; + // If we're storing a struct that defines opCmp, don't compare pointers as // that is almost certainly not what the user intended. static if (is(typeof(less) == string ) && less == "a < b" && isPointer!T && __traits(hasMember, PointerTarget!T, "opCmp")) @@ -420,7 +422,7 @@ private: n.parent = parent; n.markUsed(0); n.values[0] = cast(Value) value; - static if (supportGC && shouldAddGCRange!T) + static if (useGC) GC.addRange(n, Node.sizeof); return n; } @@ -440,7 +442,7 @@ private: if (n.right !is null) deallocateNode(n.right, allocator); - static if (supportGC && shouldAddGCRange!T) + static if (useGC) GC.removeRange(n); static if (stateSize!Allocator == 0) dispose(Allocator.instance, n);