3 ms·
My take away from a quick read: If there are N items here that all need to be processed by procedure P, the naive solution is to loop N times spoon feeding the
by greenbit 4y ago
My take away from a quick read:
If there are N items here that all need to be processed by procedure P, the naive solution is to loop N times spoon feeding the items into P. The preferred solution is to have P take a reference to entire sets of items, specifically arrays of items.
This is nice! This to me seems very sensible whether you have some fancy hardware doing P in parallel, or even just a plain old FOR loop - in the latter case it's the same length loop as the naive solution but you don't expose your procedure call mechanism to the loop. And it's a win on the calling side bc it'll help declutter the business logic there.
- dkersten 4y agoReminds me of Mike Acton’s talk on data-oriented programming, where he talked about writing functions to take arrays of things instead of single things, stating: Where there’s one, there’s many
- throwaway17_17 4y agoFor anyone interested: Mike Acton’s CPPCon Keynote 2014 is the usual reference for parent’s quote. [1] 1 - https://m.youtube.com/watch?v=rX0ItVEVjHc https://m.youtube.com/watch?v=rX0ItVEVjHc