@@ -166,8 +166,12 @@ pub fn Objects(options: ObjectsOptions, comptime T: type) type {
166
166
// all objects have been thrown on the floor. If they have, we find them and grow the
167
167
// recycling bin to fit them.
168
168
if (objs .internal .thrown_on_the_floor >= (data .len / 10 )) {
169
- var iter = dead .iterator (.{});
170
- while (iter .next ()) | index | try recycling_bin .append (allocator , @intCast (index ));
169
+ var iter = dead .iterator (.{ .kind = .set });
170
+ while (iter .next ()) | index | {
171
+ // dead bitset contains data.capacity number of entries, we only care about ones that are in data.len range.
172
+ if (index > data .len - 1 ) break ;
173
+ try recycling_bin .append (allocator , @intCast (index ));
174
+ }
171
175
objs .internal .thrown_on_the_floor = 0 ;
172
176
}
173
177
@@ -176,6 +180,7 @@ pub fn Objects(options: ObjectsOptions, comptime T: type) type {
176
180
dead .unset (index );
177
181
const gen = generation .items [index ] + 1 ;
178
182
generation .items [index ] = gen ;
183
+ data .set (index , value );
179
184
return @bitCast (PackedID {
180
185
.type_id = objs .internal .type_id ,
181
186
.generation = gen ,
@@ -185,7 +190,7 @@ pub fn Objects(options: ObjectsOptions, comptime T: type) type {
185
190
186
191
// Ensure we have space for the new object
187
192
try data .ensureUnusedCapacity (allocator , 1 );
188
- try dead .resize (allocator , data .capacity , true );
193
+ try dead .resize (allocator , data .capacity , false );
189
194
try generation .ensureUnusedCapacity (allocator , 1 );
190
195
191
196
// If we are tracking fields, we need to resize the bitset to hold another object's fields
0 commit comments