4 ms·
Two ways to interpret boxing here: 1 Storing a primitive as a first class object 2 packaging and repackaging data There may be situations where the former is
by hinkley 7y ago
Two ways to interpret boxing here:
1 Storing a primitive as a first class object
2 packaging and repackaging data
There may be situations where the former is not an issue, but the latter often is. If you don’t have a way to treat filter() as a generator/coroutine it means your traversing one collection and inserting those values into another, only to pass it to map() which iterates again and creates a third. If you’re doing that once a frame, maybe not a big deal. Three times per object per frame? That’s a lot of temporary data structures.
If the other responder is right, I speculate that the borrow checker forced someone’s hand in Rust and they found that a generator keeps the borrowed objects on the call stack where they already had tools to track ownership.
- pjc50 7y agoCorrect usage of IEnumerable helps a lot, as well as the magic that Linq can do with expressions.
- dleslie 7y agoIn my experience, the trick is to remove `using Linq` from the entire project.
- hinkley 7y agoAs someone who has had a mild case of Linq jealousy for some time, I’m curious what makes you averse.
- dleslie 7y agoIt's too easy to fall into the temporary collection trap you described; on a large project with many developers, allowing Linq is a bit like leaving a toaster plugged in beside the pool.