@@ -93,14 +93,14 @@ namespace JsUtil
9393 Pointer (int , TAllocator) buckets;
9494 Pointer (EntryType, TAllocator) entries;
9595 PointerNoBarrier (AllocatorType) alloc;
96- int size;
97- uint bucketCount;
98- int count;
99- int freeList;
100- int freeCount;
96+ Field ( int ) size;
97+ Field ( uint) bucketCount;
98+ Field ( int ) count;
99+ Field ( int ) freeList;
100+ Field ( int ) freeCount;
101101
102102#if PROFILE_DICTIONARY
103- DictionaryStats * stats;
103+ PointerNoBarrier ( DictionaryStats) stats;
104104#endif
105105 enum InsertOperations
106106 {
@@ -179,11 +179,8 @@ namespace JsUtil
179179 freeList = other.freeList ;
180180 freeCount = other.freeCount ;
181181
182- size_t copySize = bucketCount * sizeof (buckets[0 ]);
183- js_memcpy_s (buckets, copySize, other.buckets , copySize);
184-
185- copySize = size * sizeof (entries[0 ]);
186- js_memcpy_s (entries, copySize, other.entries , copySize);
182+ CopyArray<TAllocator>(buckets, bucketCount, other.buckets , bucketCount);
183+ CopyArray<TAllocator, EntryType, ValueType>(entries, size, other.entries , size);
187184
188185#if PROFILE_DICTIONARY
189186 stats = DictionaryStats::Create (typeid (this ).name (), size);
@@ -698,11 +695,8 @@ namespace JsUtil
698695 freeList = other->freeList ;
699696 freeCount = other->freeCount ;
700697
701- size_t copySize = bucketCount * sizeof (buckets[0 ]);
702- js_memcpy_s (buckets, copySize, other->buckets , copySize);
703-
704- copySize = size * sizeof (entries[0 ]);
705- js_memcpy_s (entries, copySize, other->entries , copySize);
698+ CopyArray<TAllocator>(buckets, bucketCount, other->buckets , bucketCount);
699+ CopyArray<TAllocator, EntryType, ValueType>(entries, size, other->entries , size);
706700
707701#if PROFILE_DICTIONARY
708702 stats = DictionaryStats::Create (typeid (this ).name (), size);
@@ -866,8 +860,8 @@ namespace JsUtil
866860 Allocate (&newBuckets, &newEntries, initBucketCount, initSize);
867861
868862 // Allocation can throw - assign only after allocation has succeeded.
869- SetArray<TAllocator>( this ->buckets , newBuckets, initBucketCount) ;
870- SetArray<TAllocator, EntryType, ValueType>( this ->entries , newEntries, initSize) ;
863+ this ->buckets = newBuckets ;
864+ this ->entries = newEntries ;
871865 this ->bucketCount = initBucketCount;
872866 this ->size = initSize;
873867 Assert (this ->freeCount == 0 );
@@ -1007,7 +1001,7 @@ namespace JsUtil
10071001 {
10081002 // no need to rehash
10091003 newEntries = AllocateEntries (newSize);
1010- js_memcpy_s (newEntries, sizeof ( EntryType) * newSize, entries, sizeof (EntryType) * count);
1004+ CopyArray<TAllocator, EntryType, ValueType>(newEntries, newSize, entries, count);
10111005
10121006 DeleteEntries (entries, size);
10131007
@@ -1017,7 +1011,7 @@ namespace JsUtil
10171011 }
10181012
10191013 Allocate (&newBuckets, &newEntries, newBucketCount, newSize);
1020- js_memcpy_s (newEntries, sizeof ( EntryType) * newSize, entries, sizeof (EntryType) * count);
1014+ CopyArray<TAllocator, EntryType, ValueType>(newEntries, newSize, entries, count);
10211015
10221016 // When TAllocator is of type Recycler, it is possible that the Allocate above causes a collection, which
10231017 // in turn can cause entries in the dictionary to be removed - i.e. the dictionary contains weak references
@@ -1042,8 +1036,8 @@ namespace JsUtil
10421036 if (stats)
10431037 stats->Resize (newSize, /* emptyBuckets=*/ newSize - size);
10441038#endif
1045- SetArray<TAllocator>( this ->buckets , newBuckets, newBucketCount) ;
1046- SetArray<TAllocator, EntryType, ValueType>( this ->entries , newEntries, newSize) ;
1039+ this ->buckets = newBuckets ;
1040+ this ->entries = newEntries ;
10471041 bucketCount = newBucketCount;
10481042 size = newSize;
10491043 }
@@ -1565,7 +1559,7 @@ namespace JsUtil
15651559 class SynchronizedDictionary : protected BaseDictionary <TKey, TValue, TAllocator, SizePolicy, Comparer, Entry>
15661560 {
15671561 private:
1568- SyncObject* syncObj;
1562+ PointerNoBarrier ( SyncObject) syncObj;
15691563
15701564 typedef BaseDictionary<TKey, TValue, TAllocator, SizePolicy, Comparer, Entry> Base;
15711565 public:
@@ -1817,4 +1811,3 @@ namespace JsUtil
18171811 PREVENT_COPY (SynchronizedDictionary);
18181812 };
18191813}
1820-
0 commit comments