logoalt Hacker News

tsimionescutoday at 4:00 PM2 repliesview on HN

It's because removing a monster with 20 fields from an SoA structure means resizing 20 arrays. Removing the same monster from an AoS array involves resizing a single array, which you're going to process in a very cache friendly way.


Replies

Altern4tiveAcctoday at 4:22 PM

Assuming ordering isn't a concern, can't you just have a field called "removed" and skip those when iterating?

Or swap it with the last monster, and keeping an index for the last monster alive.

show 2 replies
vouwfietsmantoday at 5:45 PM

I'm not sure why anybody would at the same time be implementing SoA AND resizing 20 arrays for a single delete, those things seem to be on either ends of the "I care about performance" spectrum.

show 1 reply