Skip to content

Commit

Permalink
Merge pull request dlang-community#59 from putao-dev/master
Browse files Browse the repository at this point in the history
fix DynamicArray ~this sgould be use useGC. ttree add useGC
  • Loading branch information
Hackerpilot committed Jun 28, 2016
2 parents a74854a + c773794 commit d3ce885
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Expand Up @@ -14,3 +14,6 @@ test/compile_test_32
test/external_allocator_test
test/external_allocator_test_32
.gdb_history
__test__*__
*.exe
.directory
2 changes: 1 addition & 1 deletion src/containers/dynamicarray.d
Expand Up @@ -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);
Expand Down
6 changes: 4 additions & 2 deletions src/containers/ttree.d
Expand Up @@ -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"))
Expand All @@ -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;
}
Expand All @@ -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);
Expand Down

0 comments on commit d3ce885

Please sign in to comment.