Nourhan Hasan would like Liam Appelbe to review this change.
[vm/service]: reuse deleted ID zone slots to bound array growth (#62205)
Adds a free list for indices, preventing unbounded
array growth on repeated create/delete cycles.
R=li...@google.com
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
I created a second array (free_service_id_zone_slots_) that tracks which indices in service_id_zones_ are empty and available for reuse.
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
const intptr_t zone_id = free_service_id_zone_slots_->Last();I don't think this is the right solution here, mainly because reusing IDs makes it easier for clients to accidentally delete ID zones using an old ID when the zone has already been reused.
The right solution would be to use a map of ID zone IDs -> ID zones instead of a growable array so that we can remove entries as zones are cleaned up.
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
const intptr_t zone_id = free_service_id_zone_slots_->Last();I don't think this is the right solution here, mainly because reusing IDs makes it easier for clients to accidentally delete ID zones using an old ID when the zone has already been reused.
The right solution would be to use a map of ID zone IDs -> ID zones instead of a growable array so that we can remove entries as zones are cleaned up.
Thanks for the feedback. I hadn't considered this case. I chose the free list approach because it requires minimal changes and retains O(1) operations while keeping the array size bounded. However, I agree that using the map would be safer and more effective, but it would require more changes, I think, so I'll see how I can implement that.
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |