mirror of
https://github.com/dlang/phobos.git
synced 2025-04-28 22:21:09 +03:00
Replace object.clear to destroy
This commit is contained in:
parent
ec773717bb
commit
72a33de959
4 changed files with 12 additions and 13 deletions
|
@ -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);
|
||||
|
@ -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];
|
||||
|
@ -1979,7 +1979,7 @@ Complexity: $(BIGOH n)
|
|||
*/
|
||||
void clear()
|
||||
{
|
||||
.clear(_data);
|
||||
.destroy(_data);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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];
|
||||
}
|
||||
|
@ -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];
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
|
|
|
@ -1392,7 +1392,7 @@ struct LockingTextReader
|
|||
_crt = FGETC(cast(_iobuf*) _f.p.handle);
|
||||
if (_crt == -1)
|
||||
{
|
||||
clear(_f);
|
||||
.destroy(_f);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
|
|
|
@ -1187,7 +1187,7 @@ Forces $(D this) to the null state.
|
|||
*/
|
||||
void nullify()()
|
||||
{
|
||||
clear(_value);
|
||||
.destroy(_value);
|
||||
_isNull = true;
|
||||
}
|
||||
|
||||
|
@ -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()
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue