@@ -48,7 +48,7 @@ struct AA
48
48
private struct Impl
49
49
{
50
50
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 )
52
52
{
53
53
keysz = cast (uint ) ti.key.tsize;
54
54
valsz = cast (uint ) ti.value.tsize;
@@ -111,7 +111,7 @@ private:
111
111
}
112
112
113
113
// 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
115
115
{
116
116
for (size_t i = hash & mask, j = 1 ;; ++ j)
117
117
{
@@ -123,7 +123,7 @@ private:
123
123
}
124
124
}
125
125
126
- void grow (in TypeInfo keyti)
126
+ void grow (scope const TypeInfo keyti)
127
127
{
128
128
// If there are so many deleted entries, that growing would push us
129
129
// below the shrink threshold, we just purge deleted entries instead.
@@ -133,7 +133,7 @@ private:
133
133
resize(GROW_FAC * dim);
134
134
}
135
135
136
- void shrink (in TypeInfo keyti)
136
+ void shrink (scope const TypeInfo keyti)
137
137
{
138
138
if (dim > INIT_NUM_BUCKETS )
139
139
resize(dim / GROW_FAC );
@@ -201,7 +201,7 @@ Bucket[] allocBuckets(size_t dim) @trusted pure nothrow
201
201
// Entry
202
202
// ------------------------------------------------------------------------------
203
203
204
- private void * allocEntry (in Impl* aa, in void * pkey)
204
+ private void * allocEntry (scope const Impl* aa, scope const void * pkey)
205
205
{
206
206
import rt.lifetime : _d_newitemU;
207
207
import core.stdc.string : memcpy, memset;
@@ -454,14 +454,14 @@ private size_t mix(size_t h) @safe pure nothrow @nogc
454
454
return h;
455
455
}
456
456
457
- private size_t calcHash (in void * pkey, in TypeInfo keyti)
457
+ private size_t calcHash (scope const void * pkey, scope const TypeInfo keyti)
458
458
{
459
459
immutable hash = keyti.getHash(pkey);
460
460
// highest bit is set to distinguish empty/deleted from filled buckets
461
461
return mix (hash) | HASH_FILLED_MARK ;
462
462
}
463
463
464
- private size_t nextpow2 (in size_t n) pure nothrow @nogc
464
+ private size_t nextpow2 (const size_t n) pure nothrow @nogc
465
465
{
466
466
import core.bitop : bsr;
467
467
@@ -494,7 +494,7 @@ private T max(T)(T a, T b) pure nothrow @nogc
494
494
// ------------------------------------------------------------------------------
495
495
496
496
// / 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
498
498
{
499
499
return aa ? aa.length : 0 ;
500
500
}
@@ -513,7 +513,7 @@ extern (C) size_t _aaLen(in AA aa) pure nothrow @nogc
513
513
* is set to all zeros
514
514
*/
515
515
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)
517
517
{
518
518
bool found;
519
519
return _aaGetX (aa, ti, valsz, pkey, found);
@@ -534,7 +534,7 @@ extern (C) void* _aaGetY(AA* aa, const TypeInfo_AssociativeArray ti,
534
534
* is set to all zeros
535
535
*/
536
536
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)
538
538
{
539
539
// lazily alloc implementation
540
540
if (aa.impl is null )
@@ -587,8 +587,8 @@ extern (C) void* _aaGetX(AA* aa, const TypeInfo_AssociativeArray ti,
587
587
* Returns:
588
588
* pointer to value if present, null otherwise
589
589
*/
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)
592
592
{
593
593
return _aaInX (aa, keyti, pkey);
594
594
}
@@ -603,7 +603,7 @@ extern (C) inout(void)* _aaGetRvalueX(inout AA aa, in TypeInfo keyti, in size_t
603
603
* Returns:
604
604
* pointer to value if present, null otherwise
605
605
*/
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)
607
607
{
608
608
if (aa.empty)
609
609
return null ;
@@ -614,8 +614,8 @@ extern (C) inout(void)* _aaInX(inout AA aa, in TypeInfo keyti, in void* pkey)
614
614
return null ;
615
615
}
616
616
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)
619
619
{
620
620
if (aa.empty)
621
621
return false ;
@@ -646,15 +646,15 @@ extern (C) void _aaClear(AA aa) pure nothrow
646
646
}
647
647
648
648
// / 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
650
650
{
651
651
if (! paa.empty)
652
652
paa.resize(nextpow2(INIT_DEN * paa.length / INIT_NUM ));
653
653
return * paa;
654
654
}
655
655
656
656
// / 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,
658
658
const TypeInfo tiValueArray) pure nothrow
659
659
{
660
660
if (aa.empty)
@@ -678,7 +678,7 @@ extern (C) inout(void[]) _aaValues(inout AA aa, in size_t keysz, in size_t valsz
678
678
}
679
679
680
680
// / 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
682
682
{
683
683
if (aa.empty)
684
684
return null ;
@@ -704,7 +704,7 @@ extern (D) alias dg_t = int delegate(void*);
704
704
extern (D ) alias dg2_t = int delegate (void * , void * );
705
705
706
706
// / 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)
708
708
{
709
709
if (aa.empty)
710
710
return 0 ;
@@ -721,7 +721,7 @@ extern (C) int _aaApply(AA aa, in size_t keysz, dg_t dg)
721
721
}
722
722
723
723
// / 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)
725
725
{
726
726
if (aa.empty)
727
727
return 0 ;
@@ -786,7 +786,7 @@ extern (C) Impl* _d_assocarrayliteralTX(const TypeInfo_AssociativeArray ti, void
786
786
}
787
787
788
788
// / 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)
790
790
{
791
791
if (aa1.impl is aa2.impl)
792
792
return true ;
@@ -816,7 +816,7 @@ extern (C) int _aaEqual(in TypeInfo tiRaw, in AA aa1, in AA aa2)
816
816
}
817
817
818
818
// / 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
820
820
{
821
821
if (aa.empty)
822
822
return 0 ;
@@ -903,7 +903,7 @@ extern (C) pure nothrow @nogc @safe
903
903
}
904
904
}
905
905
906
- // Most tests are now in in test_aa.d
906
+ // Most tests are now in test_aa.d
907
907
908
908
// test postblit for AA literals
909
909
unittest
0 commit comments