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

Commit 0cbfdbb

Browse files
authored
Merge pull request #2781 from JinShil/aa_in
Replace `in` with `scope const` in `rt.aaA.d` merged-on-behalf-of: Nicholas Wilson <thewilsonator@users.noreply.github.com>
2 parents 6fb7f66 + 3837338 commit 0cbfdbb

File tree

2 files changed

+27
-27
lines changed

2 files changed

+27
-27
lines changed

src/object.d

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -414,8 +414,8 @@ class TypeInfo_Enum : TypeInfo
414414
}
415415

416416
override size_t getHash(scope const void* p) const { return base.getHash(p); }
417-
override bool equals(in void* p1, in void* p2) const { return base.equals(p1, p2); }
418-
override int compare(in void* p1, in void* p2) const { return base.compare(p1, p2); }
417+
override bool equals(scope const void* p1, scope const void* p2) const { return base.equals(p1, p2); }
418+
override int compare(scope const void* p1, scope const void* p2) const { return base.compare(p1, p2); }
419419
override @property size_t tsize() nothrow pure const { return base.tsize; }
420420
override void swap(void* p1, void* p2) const { return base.swap(p1, p2); }
421421

@@ -2147,8 +2147,8 @@ extern (C)
21472147
void* _aaRangeFrontValue(AARange r) pure nothrow @nogc @safe;
21482148
void _aaRangePopFront(ref AARange r) pure nothrow @nogc @safe;
21492149

2150-
int _aaEqual(in TypeInfo tiRaw, in AA aa1, in AA aa2);
2151-
hash_t _aaGetHash(in AA* aa, in TypeInfo tiRaw) nothrow;
2150+
int _aaEqual(scope const TypeInfo tiRaw, scope const AA aa1, scope const AA aa2);
2151+
hash_t _aaGetHash(scope const AA* aa, scope const TypeInfo tiRaw) nothrow;
21522152

21532153
/*
21542154
_d_assocarrayliteralTX marked as pure, because aaLiteral can be called from pure code.

src/rt/aaA.d

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ struct AA
4848
private struct Impl
4949
{
5050
private:
51-
this(in TypeInfo_AssociativeArray ti, size_t sz = INIT_NUM_BUCKETS)
51+
this(scope const TypeInfo_AssociativeArray ti, size_t sz = INIT_NUM_BUCKETS)
5252
{
5353
keysz = cast(uint) ti.key.tsize;
5454
valsz = cast(uint) ti.value.tsize;
@@ -111,7 +111,7 @@ private:
111111
}
112112

113113
// lookup a key
114-
inout(Bucket)* findSlotLookup(size_t hash, in void* pkey, in TypeInfo keyti) inout
114+
inout(Bucket)* findSlotLookup(size_t hash, scope const void* pkey, scope const TypeInfo keyti) inout
115115
{
116116
for (size_t i = hash & mask, j = 1;; ++j)
117117
{
@@ -123,7 +123,7 @@ private:
123123
}
124124
}
125125

126-
void grow(in TypeInfo keyti)
126+
void grow(scope const TypeInfo keyti)
127127
{
128128
// If there are so many deleted entries, that growing would push us
129129
// below the shrink threshold, we just purge deleted entries instead.
@@ -133,7 +133,7 @@ private:
133133
resize(GROW_FAC * dim);
134134
}
135135

136-
void shrink(in TypeInfo keyti)
136+
void shrink(scope const TypeInfo keyti)
137137
{
138138
if (dim > INIT_NUM_BUCKETS)
139139
resize(dim / GROW_FAC);
@@ -201,7 +201,7 @@ Bucket[] allocBuckets(size_t dim) @trusted pure nothrow
201201
// Entry
202202
//------------------------------------------------------------------------------
203203

204-
private void* allocEntry(in Impl* aa, in void* pkey)
204+
private void* allocEntry(scope const Impl* aa, scope const void* pkey)
205205
{
206206
import rt.lifetime : _d_newitemU;
207207
import core.stdc.string : memcpy, memset;
@@ -454,14 +454,14 @@ private size_t mix(size_t h) @safe pure nothrow @nogc
454454
return h;
455455
}
456456

457-
private size_t calcHash(in void* pkey, in TypeInfo keyti)
457+
private size_t calcHash(scope const void* pkey, scope const TypeInfo keyti)
458458
{
459459
immutable hash = keyti.getHash(pkey);
460460
// highest bit is set to distinguish empty/deleted from filled buckets
461461
return mix(hash) | HASH_FILLED_MARK;
462462
}
463463

464-
private size_t nextpow2(in size_t n) pure nothrow @nogc
464+
private size_t nextpow2(const size_t n) pure nothrow @nogc
465465
{
466466
import core.bitop : bsr;
467467

@@ -494,7 +494,7 @@ private T max(T)(T a, T b) pure nothrow @nogc
494494
//------------------------------------------------------------------------------
495495

496496
/// Determine number of entries in associative array.
497-
extern (C) size_t _aaLen(in AA aa) pure nothrow @nogc
497+
extern (C) size_t _aaLen(scope const AA aa) pure nothrow @nogc
498498
{
499499
return aa ? aa.length : 0;
500500
}
@@ -513,7 +513,7 @@ extern (C) size_t _aaLen(in AA aa) pure nothrow @nogc
513513
* is set to all zeros
514514
*/
515515
extern (C) void* _aaGetY(AA* aa, const TypeInfo_AssociativeArray ti,
516-
in size_t valsz, in void* pkey)
516+
const size_t valsz, scope const void* pkey)
517517
{
518518
bool found;
519519
return _aaGetX(aa, ti, valsz, pkey, found);
@@ -534,7 +534,7 @@ extern (C) void* _aaGetY(AA* aa, const TypeInfo_AssociativeArray ti,
534534
* is set to all zeros
535535
*/
536536
extern (C) void* _aaGetX(AA* aa, const TypeInfo_AssociativeArray ti,
537-
in size_t valsz, in void* pkey, out bool found)
537+
const size_t valsz, scope const void* pkey, out bool found)
538538
{
539539
// lazily alloc implementation
540540
if (aa.impl is null)
@@ -587,8 +587,8 @@ extern (C) void* _aaGetX(AA* aa, const TypeInfo_AssociativeArray ti,
587587
* Returns:
588588
* pointer to value if present, null otherwise
589589
*/
590-
extern (C) inout(void)* _aaGetRvalueX(inout AA aa, in TypeInfo keyti, in size_t valsz,
591-
in void* pkey)
590+
extern (C) inout(void)* _aaGetRvalueX(inout AA aa, scope const TypeInfo keyti, const size_t valsz,
591+
scope const void* pkey)
592592
{
593593
return _aaInX(aa, keyti, pkey);
594594
}
@@ -603,7 +603,7 @@ extern (C) inout(void)* _aaGetRvalueX(inout AA aa, in TypeInfo keyti, in size_t
603603
* Returns:
604604
* pointer to value if present, null otherwise
605605
*/
606-
extern (C) inout(void)* _aaInX(inout AA aa, in TypeInfo keyti, in void* pkey)
606+
extern (C) inout(void)* _aaInX(inout AA aa, scope const TypeInfo keyti, scope const void* pkey)
607607
{
608608
if (aa.empty)
609609
return null;
@@ -614,8 +614,8 @@ extern (C) inout(void)* _aaInX(inout AA aa, in TypeInfo keyti, in void* pkey)
614614
return null;
615615
}
616616

617-
/// Delete entry in AA, return true if it was present
618-
extern (C) bool _aaDelX(AA aa, in TypeInfo keyti, in void* pkey)
617+
/// Delete entry scope const AA, return true if it was present
618+
extern (C) bool _aaDelX(AA aa, scope const TypeInfo keyti, scope const void* pkey)
619619
{
620620
if (aa.empty)
621621
return false;
@@ -646,15 +646,15 @@ extern (C) void _aaClear(AA aa) pure nothrow
646646
}
647647

648648
/// Rehash AA
649-
extern (C) void* _aaRehash(AA* paa, in TypeInfo keyti) pure nothrow
649+
extern (C) void* _aaRehash(AA* paa, scope const TypeInfo keyti) pure nothrow
650650
{
651651
if (!paa.empty)
652652
paa.resize(nextpow2(INIT_DEN * paa.length / INIT_NUM));
653653
return *paa;
654654
}
655655

656656
/// Return a GC allocated array of all values
657-
extern (C) inout(void[]) _aaValues(inout AA aa, in size_t keysz, in size_t valsz,
657+
extern (C) inout(void[]) _aaValues(inout AA aa, const size_t keysz, const size_t valsz,
658658
const TypeInfo tiValueArray) pure nothrow
659659
{
660660
if (aa.empty)
@@ -678,7 +678,7 @@ extern (C) inout(void[]) _aaValues(inout AA aa, in size_t keysz, in size_t valsz
678678
}
679679

680680
/// Return a GC allocated array of all keys
681-
extern (C) inout(void[]) _aaKeys(inout AA aa, in size_t keysz, const TypeInfo tiKeyArray) pure nothrow
681+
extern (C) inout(void[]) _aaKeys(inout AA aa, const size_t keysz, const TypeInfo tiKeyArray) pure nothrow
682682
{
683683
if (aa.empty)
684684
return null;
@@ -704,7 +704,7 @@ extern (D) alias dg_t = int delegate(void*);
704704
extern (D) alias dg2_t = int delegate(void*, void*);
705705

706706
/// foreach opApply over all values
707-
extern (C) int _aaApply(AA aa, in size_t keysz, dg_t dg)
707+
extern (C) int _aaApply(AA aa, const size_t keysz, dg_t dg)
708708
{
709709
if (aa.empty)
710710
return 0;
@@ -721,7 +721,7 @@ extern (C) int _aaApply(AA aa, in size_t keysz, dg_t dg)
721721
}
722722

723723
/// foreach opApply over all key/value pairs
724-
extern (C) int _aaApply2(AA aa, in size_t keysz, dg2_t dg)
724+
extern (C) int _aaApply2(AA aa, const size_t keysz, dg2_t dg)
725725
{
726726
if (aa.empty)
727727
return 0;
@@ -786,7 +786,7 @@ extern (C) Impl* _d_assocarrayliteralTX(const TypeInfo_AssociativeArray ti, void
786786
}
787787

788788
/// compares 2 AAs for equality
789-
extern (C) int _aaEqual(in TypeInfo tiRaw, in AA aa1, in AA aa2)
789+
extern (C) int _aaEqual(scope const TypeInfo tiRaw, scope const AA aa1, scope const AA aa2)
790790
{
791791
if (aa1.impl is aa2.impl)
792792
return true;
@@ -816,7 +816,7 @@ extern (C) int _aaEqual(in TypeInfo tiRaw, in AA aa1, in AA aa2)
816816
}
817817

818818
/// compute a hash
819-
extern (C) hash_t _aaGetHash(in AA* aa, in TypeInfo tiRaw) nothrow
819+
extern (C) hash_t _aaGetHash(scope const AA* aa, scope const TypeInfo tiRaw) nothrow
820820
{
821821
if (aa.empty)
822822
return 0;
@@ -903,7 +903,7 @@ extern (C) pure nothrow @nogc @safe
903903
}
904904
}
905905

906-
// Most tests are now in in test_aa.d
906+
// Most tests are now in test_aa.d
907907

908908
// test postblit for AA literals
909909
unittest

0 commit comments

Comments
 (0)