Skip to content

Commit

Permalink
Fixed std.algorithm imports in std.experimental.allocator to not be p…
Browse files Browse the repository at this point in the history
…ackage wide
  • Loading branch information
JackStouffer committed Jul 3, 2016
1 parent b954b59 commit c183c2e
Show file tree
Hide file tree
Showing 12 changed files with 24 additions and 26 deletions.
Expand Up @@ -23,7 +23,7 @@ struct AffixAllocator(Allocator, Prefix, Suffix = void)
import std.experimental.allocator.common : stateSize, forwardToMember,
roundUpToMultipleOf, alignedAt, alignDownTo, roundUpToMultipleOf;
import std.traits : hasMember;
import std.algorithm : min;
import std.algorithm.comparison : min;
import std.typecons : Ternary;
import std.math : isPowerOf2;

Expand Down
9 changes: 4 additions & 5 deletions std/experimental/allocator/building_blocks/allocator_list.d
Expand Up @@ -65,7 +65,6 @@ struct AllocatorList(Factory, BookkeepingAllocator = GCAllocator)
{
import std.traits : hasMember;
import std.conv : emplace;
import std.algorithm : min, move;
import std.typecons : Ternary;
import std.experimental.allocator.building_blocks.stats_collector
: StatsCollector, Options;
Expand Down Expand Up @@ -535,7 +534,7 @@ template AllocatorList(alias factoryFunction,
///
version(Posix) unittest
{
import std.algorithm : max;
import std.algorithm.comparison : max;
import std.experimental.allocator.building_blocks.region : Region;
import std.experimental.allocator.mmap_allocator : MmapAllocator;
import std.experimental.allocator.building_blocks.segregator : Segregator;
Expand Down Expand Up @@ -578,7 +577,7 @@ version(Posix) unittest
unittest
{
// Create an allocator based upon 4MB regions, fetched from the GC heap.
import std.algorithm : max;
import std.algorithm.comparison : max;
import std.experimental.allocator.building_blocks.region : Region;
AllocatorList!((n) => Region!GCAllocator(new void[max(n, 1024 * 4096)]),
NullAllocator) a;
Expand All @@ -592,7 +591,7 @@ unittest
unittest
{
// Create an allocator based upon 4MB regions, fetched from the GC heap.
import std.algorithm : max;
import std.algorithm.comparison : max;
import std.experimental.allocator.building_blocks.region : Region;
AllocatorList!((n) => Region!()(new void[max(n, 1024 * 4096)])) a;
auto b1 = a.allocate(1024 * 8192);
Expand All @@ -604,7 +603,7 @@ unittest

unittest
{
import std.algorithm : max;
import std.algorithm.comparison : max;
import std.experimental.allocator.building_blocks.region : Region;
import std.typecons : Ternary;
AllocatorList!((n) => Region!()(new void[max(n, 1024 * 4096)])) a;
Expand Down
6 changes: 3 additions & 3 deletions std/experimental/allocator/building_blocks/bitmapped_block.d
Expand Up @@ -53,7 +53,7 @@ struct BitmappedBlock(size_t theBlockSize, uint theAlignment = platformAlignment
unittest
{
import std.experimental.allocator.mallocator : AlignedMallocator;
import std.algorithm : max;
import std.algorithm.comparison : max;
auto m = AlignedMallocator.instance.alignedAllocate(1024 * 64,
max(theAlignment, cast(uint) size_t.sizeof));
scope(exit) AlignedMallocator.instance.deallocate(m);
Expand Down Expand Up @@ -127,7 +127,7 @@ struct BitmappedBlock(size_t theBlockSize, uint theAlignment = platformAlignment
{
auto blocks = capacity.divideRoundUp(blockSize);
auto leadingUlongs = blocks.divideRoundUp(64);
import std.algorithm : min;
import std.algorithm.comparison : min;
immutable initialAlignment = min(parentAlignment,
1U << trailingZeros(leadingUlongs * 8));
auto maxSlack = alignment <= initialAlignment
Expand Down Expand Up @@ -712,7 +712,7 @@ unittest
{
static void testAllocateAll(size_t bs)(uint blocks, uint blocksAtATime)
{
import std.algorithm : min;
import std.algorithm.comparison : min;
assert(bs);
import std.experimental.allocator.gc_allocator : GCAllocator;
auto a = BitmappedBlock!(bs, min(bs, platformAlignment))(
Expand Down
2 changes: 1 addition & 1 deletion std/experimental/allocator/building_blocks/bucketizer.d
Expand Up @@ -225,7 +225,7 @@ unittest
import std.experimental.allocator.mallocator : Mallocator;
import std.experimental.allocator.common : unbounded;
import std.typecons : Ternary;
import std.algorithm : max;
import std.algorithm.comparison : max;
Bucketizer!(
FreeList!(
AllocatorList!(
Expand Down
Expand Up @@ -284,7 +284,7 @@ private auto ref forward(alias arg)()
}
else
{
import std.algorithm : move;
import std.algorithm.mutation : move;
return move(arg);
}
}
Expand Down Expand Up @@ -327,7 +327,6 @@ FallbackAllocator!(Primary, Fallback)
fallbackAllocator(Primary, Fallback)(auto ref Primary p, auto ref Fallback f)
{
alias R = FallbackAllocator!(Primary, Fallback);
import std.algorithm : move;

static if (stateSize!Primary)
static if (stateSize!Fallback)
Expand Down
3 changes: 2 additions & 1 deletion std/experimental/allocator/building_blocks/free_tree.d
Expand Up @@ -52,7 +52,8 @@ struct FreeTree(ParentAllocator)
static assert(ParentAllocator.alignment % size_t.alignof == 0,
"FreeTree must be on top of a word-aligned allocator");

import std.algorithm : min, max, swap;
import std.algorithm.comparison : min, max;
import std.algorithm.mutation : swap;
import std.traits : hasMember;

// State
Expand Down
10 changes: 5 additions & 5 deletions std/experimental/allocator/building_blocks/kernighan_ritchie.d
Expand Up @@ -620,7 +620,7 @@ it actually returns memory to the operating system when possible.
*/
unittest
{
import std.algorithm : max;
import std.algorithm.comparison : max;
import std.experimental.allocator.gc_allocator : GCAllocator;
import std.experimental.allocator.mmap_allocator : MmapAllocator;
import std.experimental.allocator.building_blocks.allocator_list
Expand All @@ -630,7 +630,7 @@ unittest

unittest
{
import std.algorithm : max;
import std.algorithm.comparison : max;
import std.experimental.allocator.gc_allocator : GCAllocator;
import std.typecons : Ternary;
import std.experimental.allocator.mallocator : Mallocator;
Expand Down Expand Up @@ -663,7 +663,7 @@ unittest

unittest
{
import std.algorithm : max;
import std.algorithm.comparison : max;
import std.experimental.allocator.gc_allocator : GCAllocator;
import std.typecons : Ternary;
import std.experimental.allocator.mmap_allocator : MmapAllocator;
Expand Down Expand Up @@ -704,7 +704,7 @@ unittest
import std.experimental.allocator.gc_allocator : GCAllocator;
import std.experimental.allocator.building_blocks.allocator_list
: AllocatorList;
import std.algorithm : max;
import std.algorithm.comparison : max;
import std.experimental.allocator.common : testAllocator;
testAllocator!(() => AllocatorList!(
n => KRRegion!GCAllocator(max(n * 16, 1024 * 1024)))());
Expand Down Expand Up @@ -736,7 +736,7 @@ unittest
const store = alloc.allocate(KRRegion!().sizeof);
auto p = cast(KRRegion!()* ) store.ptr;
import std.conv : emplace;
import std.algorithm : move;
import std.algorithm.mutation : move;
import core.stdc.string : memcpy;

memcpy(p, &alloc, alloc.sizeof);
Expand Down
4 changes: 2 additions & 2 deletions std/experimental/allocator/building_blocks/region.d
Expand Up @@ -332,7 +332,7 @@ unittest
import std.experimental.allocator.mallocator : Mallocator;
import std.experimental.allocator.building_blocks.allocator_list
: AllocatorList;
import std.algorithm : max;
import std.algorithm.comparison : max;
// Create a scalable list of regions. Each gets at least 1MB at a time by
// using malloc.
auto batchAllocator = AllocatorList!(
Expand Down Expand Up @@ -375,7 +375,7 @@ hot memory is used first.
*/
struct InSituRegion(size_t size, size_t minAlign = platformAlignment)
{
import std.algorithm : max;
import std.algorithm.comparison : max;
import std.conv : to;
import std.traits : hasMember;
import std.typecons : Ternary;
Expand Down
2 changes: 1 addition & 1 deletion std/experimental/allocator/building_blocks/segregator.d
Expand Up @@ -14,7 +14,7 @@ shared) methods.
*/
struct Segregator(size_t threshold, SmallAllocator, LargeAllocator)
{
import std.algorithm : min;
import std.algorithm.comparison : min;
import std.traits : hasMember;
import std.typecons : Ternary;

Expand Down
6 changes: 3 additions & 3 deletions std/experimental/allocator/package.d
Expand Up @@ -433,7 +433,7 @@ propagates the exception.
*/
auto make(T, Allocator, A...)(auto ref Allocator alloc, auto ref A args)
{
import std.algorithm : max;
import std.algorithm.comparison : max;
import std.conv : emplace;
auto m = alloc.allocate(max(stateSize!T, 1));
if (!m.ptr) return null;
Expand Down Expand Up @@ -922,7 +922,7 @@ bool expandArray(T, Allocator)(auto ref Allocator alloc, ref T[] array,
immutable oldLength = array.length;
array = cast(T[]) buf;
scope(failure) array[oldLength .. $].uninitializedFillDefault;
import std.algorithm : uninitializedFill;
import std.algorithm.mutation : uninitializedFill;
array[oldLength .. $].uninitializedFill(init);
return true;
}
Expand Down Expand Up @@ -1261,7 +1261,7 @@ if (!isPointer!A)
// This is sensitive... create on the stack and then move
enum s = stateSize!(CAllocatorImpl!A).divideRoundUp(ulong.sizeof);
ulong[s] state;
import std.algorithm : move;
import std.algorithm.mutation : move;
emplace!(CAllocatorImpl!A)(state[], move(a));
auto dynState = a.allocate(stateSize!(CAllocatorImpl!A));
// Bitblast the object in its final destination
Expand Down
2 changes: 1 addition & 1 deletion std/experimental/allocator/showcase.d
Expand Up @@ -61,7 +61,7 @@ auto mmapRegionList(size_t bytesPerRegion)
static struct Factory
{
size_t bytesPerRegion;
private import std.algorithm : max;
private import std.algorithm.comparison : max;
private import std.experimental.allocator.building_blocks.region
: Region;
private import std.experimental.allocator.mmap_allocator
Expand Down
1 change: 0 additions & 1 deletion std/experimental/allocator/typed.d
Expand Up @@ -15,7 +15,6 @@ import std.experimental.allocator;
import std.experimental.allocator.common;
import std.traits : isPointer, hasElaborateDestructor;
import std.typecons : Flag, Yes, No;
import std.algorithm : min;
import std.range : isInputRange, isForwardRange, walkLength, save, empty,
front, popFront;

Expand Down

0 comments on commit c183c2e

Please sign in to comment.