Skip to content

Commit

Permalink
Replace object.clear to destroy
Browse files Browse the repository at this point in the history
  • Loading branch information
9rnsr committed May 31, 2012
1 parent ec77371 commit 72a33de
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 13 deletions.
10 changes: 5 additions & 5 deletions std/container.d
Original file line number Diff line number Diff line change
Expand Up @@ -1483,7 +1483,7 @@ struct Array(T) if (!is(T : const(bool)))
// Destructor releases array memory
~this()
{
foreach (ref e; _payload) .clear(e);
foreach (ref e; _payload) .destroy(e);
static if (hasIndirections!T)
GC.removeRange(_payload.ptr);
free(_payload.ptr);
Expand Down Expand Up @@ -1525,7 +1525,7 @@ struct Array(T) if (!is(T : const(bool)))
{
foreach (ref e; _payload.ptr[newLength .. _payload.length])
{
.clear(e);
.destroy(e);
}
}
_payload = _payload.ptr[0 .. newLength];
Expand Down Expand Up @@ -1979,7 +1979,7 @@ Complexity: $(BIGOH n)
*/
void clear()
{
.clear(_data);
.destroy(_data);
}

/**
Expand Down Expand Up @@ -2056,7 +2056,7 @@ Complexity: $(BIGOH log(n)).
static if (is(T == struct))
{
// Destroy this guy
.clear(_data._payload[$ - 1]);
.destroy(_data._payload[$ - 1]);
}
_data._payload = _data._payload[0 .. $ - 1];
}
Expand Down Expand Up @@ -2084,7 +2084,7 @@ Complexity: $(BIGOH howMany).
// Destroy this guy
foreach (ref e; _data._payload[$ - howMany .. $])
{
.clear(e);
.destroy(e);
}
}
_data._payload = _data._payload[0 .. $ - howMany];
Expand Down
3 changes: 1 addition & 2 deletions std/regex.d
Original file line number Diff line number Diff line change
Expand Up @@ -695,8 +695,7 @@ Trie[const(CodepointSet)] trieCache;
return *p;
if(trieCache.length == maxCachedTries)
{
trieCache.clear();
trieCache = null;
.destroy(trieCache);
}
return (trieCache[set] = Trie(set));
}
Expand Down
2 changes: 1 addition & 1 deletion std/stdio.d
Original file line number Diff line number Diff line change
Expand Up @@ -1392,7 +1392,7 @@ struct LockingTextReader
_crt = FGETC(cast(_iobuf*) _f.p.handle);
if (_crt == -1)
{
clear(_f);
.destroy(_f);
return true;
}
else
Expand Down
10 changes: 5 additions & 5 deletions std/typecons.d
Original file line number Diff line number Diff line change
Expand Up @@ -1187,7 +1187,7 @@ Forces $(D this) to the null state.
*/
void nullify()()
{
clear(_value);
.destroy(_value);
_isNull = true;
}

Expand Down Expand Up @@ -2589,7 +2589,7 @@ Constructor that tracks the reference count appropriately. If $(D
/**
Destructor that tracks the reference count appropriately. If $(D
!refCountedIsInitialized), does nothing. When the reference count goes
down to zero, calls $(D clear) agaist the payload and calls $(D free)
down to zero, calls $(D destroy) agaist the payload and calls $(D free)
to deallocate the corresponding resource.
*/
~this()
Expand All @@ -2612,7 +2612,7 @@ to deallocate the corresponding resource.
}
// Done, deallocate
assert(RefCounted._store);
clear(RefCounted._store._payload);
.destroy(RefCounted._store._payload);
if (hasIndirections!T && RefCounted._store)
GC.removeRange(RefCounted._store);
free(RefCounted._store);
Expand Down Expand Up @@ -3116,9 +3116,9 @@ unittest

~this()
{
// `clear` will also write .init but we have no functions in druntime
// `destroy` will also write .init but we have no functions in druntime
// for deterministic finalization and memory releasing for now.
clear(Scoped_payload);
.destroy(Scoped_payload);
}
}

Expand Down

0 comments on commit 72a33de

Please sign in to comment.