Skip to content
This repository has been archived by the owner on Oct 12, 2022. It is now read-only.

Commit

Permalink
Merge pull request #1639 from WalterBright/rm-PostBlitType
Browse files Browse the repository at this point in the history
refactor: eliminate unnecessary _PostBlitType template
  • Loading branch information
andralex committed Aug 30, 2016
2 parents d3626d0 + 5fbb535 commit e8ab5ca
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions src/object.d
Expand Up @@ -3380,28 +3380,27 @@ private U[] _dup(T, U)(scope T[] a) // pure nothrow depends on postblit
private extern (C) void[] _d_newarrayU(const TypeInfo ti, size_t length) pure nothrow;


private template _PostBlitType(T)
{
// assume that ref T and void* are equivalent in abi level.
static if (is(T == struct))
alias _PostBlitType = typeof(function (ref T t){ T a = t; });
else
alias _PostBlitType = typeof(delegate (ref T t){ T a = t; });
}

// Returns null, or a delegate to call postblit of T
/**************
* Get the postblit for type T.
* Returns:
* null if no postblit is necessary
* function pointer for struct postblits
* delegate for class postblits
*/
private auto _getPostblit(T)() @trusted pure nothrow @nogc
{
// infer static postblit type, run postblit if any
static if (is(T == struct))
{
import core.internal.traits : Unqual;
// use typeid(Unqual!T) here to skip TypeInfo_Const/Shared/...
return cast(_PostBlitType!T)typeid(Unqual!T).xpostblit;
alias _PostBlitType = typeof(function (ref T t){ T a = t; });
return cast(_PostBlitType)typeid(Unqual!T).xpostblit;
}
else if ((&typeid(T).postblit).funcptr !is &TypeInfo.postblit)
{
return cast(_PostBlitType!T)&typeid(T).postblit;
alias _PostBlitType = typeof(delegate (ref T t){ T a = t; });
return cast(_PostBlitType)&typeid(T).postblit;
}
else
return null;
Expand Down

0 comments on commit e8ab5ca

Please sign in to comment.