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

Commit e8ab5ca

Browse files
authored
Merge pull request #1639 from WalterBright/rm-PostBlitType
refactor: eliminate unnecessary _PostBlitType template
2 parents d3626d0 + 5fbb535 commit e8ab5ca

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

src/object.d

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3380,28 +3380,27 @@ private U[] _dup(T, U)(scope T[] a) // pure nothrow depends on postblit
33803380
private extern (C) void[] _d_newarrayU(const TypeInfo ti, size_t length) pure nothrow;
33813381

33823382

3383-
private template _PostBlitType(T)
3384-
{
3385-
// assume that ref T and void* are equivalent in abi level.
3386-
static if (is(T == struct))
3387-
alias _PostBlitType = typeof(function (ref T t){ T a = t; });
3388-
else
3389-
alias _PostBlitType = typeof(delegate (ref T t){ T a = t; });
3390-
}
3391-
3392-
// Returns null, or a delegate to call postblit of T
3383+
/**************
3384+
* Get the postblit for type T.
3385+
* Returns:
3386+
* null if no postblit is necessary
3387+
* function pointer for struct postblits
3388+
* delegate for class postblits
3389+
*/
33933390
private auto _getPostblit(T)() @trusted pure nothrow @nogc
33943391
{
33953392
// infer static postblit type, run postblit if any
33963393
static if (is(T == struct))
33973394
{
33983395
import core.internal.traits : Unqual;
33993396
// use typeid(Unqual!T) here to skip TypeInfo_Const/Shared/...
3400-
return cast(_PostBlitType!T)typeid(Unqual!T).xpostblit;
3397+
alias _PostBlitType = typeof(function (ref T t){ T a = t; });
3398+
return cast(_PostBlitType)typeid(Unqual!T).xpostblit;
34013399
}
34023400
else if ((&typeid(T).postblit).funcptr !is &TypeInfo.postblit)
34033401
{
3404-
return cast(_PostBlitType!T)&typeid(T).postblit;
3402+
alias _PostBlitType = typeof(delegate (ref T t){ T a = t; });
3403+
return cast(_PostBlitType)&typeid(T).postblit;
34053404
}
34063405
else
34073406
return null;

0 commit comments

Comments
 (0)