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

Commit

Permalink
Issue 3882: Remove pure qualifiers from assumeSafeAppend and _d_array…
Browse files Browse the repository at this point in the history
…shrinkfit prevent calls from being optimized away
  • Loading branch information
nordlow committed Mar 20, 2014
1 parent b705da5 commit a17bf88
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
5 changes: 2 additions & 3 deletions src/object.di
Expand Up @@ -536,7 +536,7 @@ template _isStaticArray(T)

private
{
extern (C) void _d_arrayshrinkfit(TypeInfo ti, void[] arr) pure nothrow;
extern (C) void _d_arrayshrinkfit(TypeInfo ti, void[] arr) nothrow;
extern (C) size_t _d_arraysetcapacity(TypeInfo ti, size_t newcapacity, void *arrptr) pure nothrow;
}

Expand All @@ -550,7 +550,7 @@ size_t reserve(T)(ref T[] arr, size_t newcapacity) pure nothrow @trusted
return _d_arraysetcapacity(typeid(T[]), newcapacity, cast(void *)&arr);
}

auto ref inout(T[]) assumeSafeAppend(T)(auto ref inout(T[]) arr) pure nothrow
auto ref inout(T[]) assumeSafeAppend(T)(auto ref inout(T[]) arr) nothrow
{
_d_arrayshrinkfit(typeid(T[]), *(cast(void[]*)&arr));
return arr;
Expand Down Expand Up @@ -626,4 +626,3 @@ version (unittest)
}
}
}

4 changes: 2 additions & 2 deletions src/object_.d
Expand Up @@ -32,7 +32,7 @@ private

extern (C) void onOutOfMemoryError() @trusted /* pure dmd @@@BUG11461@@@ */ nothrow;
extern (C) Object _d_newclass(const TypeInfo_Class ci);
extern (C) void _d_arrayshrinkfit(const TypeInfo ti, void[] arr) pure nothrow;
extern (C) void _d_arrayshrinkfit(const TypeInfo ti, void[] arr) nothrow;
extern (C) size_t _d_arraysetcapacity(const TypeInfo ti, size_t newcapacity, void *arrptr) pure nothrow;
extern (C) void rt_finalize(void *data, bool det=true);
}
Expand Down Expand Up @@ -2522,7 +2522,7 @@ unittest
* Returns:
* The input is returned.
*/
auto ref inout(T[]) assumeSafeAppend(T)(auto ref inout(T[]) arr) pure nothrow
auto ref inout(T[]) assumeSafeAppend(T)(auto ref inout(T[]) arr) nothrow
{
_d_arrayshrinkfit(typeid(T[]), *(cast(void[]*)&arr));
return arr;
Expand Down

0 comments on commit a17bf88

Please sign in to comment.