Skip to content

Commit d3ce885

Browse files
authored
Merge pull request #59 from putao-dev/master
fix DynamicArray ~this sgould be use useGC. ttree add useGC
2 parents a74854a + c773794 commit d3ce885

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,6 @@ test/compile_test_32
1414
test/external_allocator_test
1515
test/external_allocator_test_32
1616
.gdb_history
17+
__test__*__
18+
*.exe
19+
.directory

src/containers/dynamicarray.d

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ struct DynamicArray(T, Allocator = Mallocator, bool supportGC = shouldAddGCRange
5959
else
6060
typeid(T).destroy(&item);
6161
}
62-
static if (shouldAddGCRange!T)
62+
static if (useGC)
6363
{
6464
import core.memory : GC;
6565
GC.removeRange(arr.ptr);

src/containers/ttree.d

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,8 @@ private:
395395

396396
enum RangeType : ubyte { all, lower, equal, upper }
397397

398+
enum bool useGC = supportGC && shouldAddGCRange!T;
399+
398400
// If we're storing a struct that defines opCmp, don't compare pointers as
399401
// that is almost certainly not what the user intended.
400402
static if (is(typeof(less) == string ) && less == "a < b" && isPointer!T && __traits(hasMember, PointerTarget!T, "opCmp"))
@@ -420,7 +422,7 @@ private:
420422
n.parent = parent;
421423
n.markUsed(0);
422424
n.values[0] = cast(Value) value;
423-
static if (supportGC && shouldAddGCRange!T)
425+
static if (useGC)
424426
GC.addRange(n, Node.sizeof);
425427
return n;
426428
}
@@ -440,7 +442,7 @@ private:
440442
if (n.right !is null)
441443
deallocateNode(n.right, allocator);
442444

443-
static if (supportGC && shouldAddGCRange!T)
445+
static if (useGC)
444446
GC.removeRange(n);
445447
static if (stateSize!Allocator == 0)
446448
dispose(Allocator.instance, n);

0 commit comments

Comments
 (0)