File tree Expand file tree Collapse file tree 2 files changed +18
-13
lines changed
IGC/AdaptorCommon/RayTracing/API/ADT Expand file tree Collapse file tree 2 files changed +18
-13
lines changed Original file line number Diff line number Diff line change @@ -114,7 +114,7 @@ template <typename T> class Array {
114
114
End = Start + NumElts;
115
115
116
116
for (uint32_t i = 0 ; i < NumElts; i++)
117
- Start[i] = typename iterator::value_type () ;
117
+ new (& Start[i]) typename iterator::value_type;
118
118
}
119
119
120
120
Array &operator =(const Array &) = delete ;
Original file line number Diff line number Diff line change @@ -94,19 +94,24 @@ class UnorderedMap {
94
94
if (idx < Keys.size ()) {
95
95
Values[idx] = std::move (value);
96
96
} else {
97
- // Grow arrays by 1
98
- Array<KeyT> newKeys (Keys.size () + 1 );
99
- Array<ValueT> newValues (Values.size () + 1 );
100
- for (size_t i = 0 ; i < Keys.size (); ++i) {
101
- newKeys[i] = Keys[i];
102
- newValues[i] = std::move (Values[i]);
97
+ uint32_t currSize = Keys.size ();
98
+
99
+ Array<KeyT> oldKeys = std::move (Keys);
100
+ Array<ValueT> oldValues = std::move (Values);
101
+
102
+ Keys = Array<KeyT>(currSize + 1 );
103
+ Values = Array<ValueT>(currSize + 1 );
104
+
105
+ for (uint32_t i = 0 ; i < currSize; ++i) {
106
+ Keys[i] = std::move (oldKeys[i]);
107
+ Values[i] = std::move (oldValues[i]);
103
108
}
104
- newKeys[Keys. size ()] = key;
105
- newValues[Values. size () ] = std::move (value) ;
106
- Keys. destroy ( );
107
- Values. destroy ();
108
- Keys = std::move (newKeys );
109
- Values = std::move (newValues );
109
+
110
+ Keys[currSize ] = key ;
111
+ Values[currSize] = std::move (value );
112
+
113
+ oldKeys. destroy ( );
114
+ oldValues. destroy ( );
110
115
}
111
116
}
112
117
You can’t perform that action at this time.
0 commit comments