Comment

Comment by cowlevel

It's not about that, it's about avoiding copying to a function parameter. If you want a function that adds a bunch of integers, you should write it as "int sum(vector<int> const&)" rather than "int sum(vector<int>)" because the latter will copy the whole array of numbers just to sum them and delete the copy, when you could have summed the original array with no downside. Arguably it should be span<int> though now that exists.
parent cowlevel 1 day ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton