Stackalloc a span of tuples?
Is it possible to stackalloc a span of tuples like this?
Span<(object, string)> foos = stackalloc (object, string)[12];
10 Replies
Zeth
REPL Result: Success
Compile: 306.049ms | Execution: 28.801ms | React with ❌ to remove this embed.
gotcha
does
additionalSources have a small bounded length?not bounded, but generally quite small, yeah
it's just a helper fn for multi binding
if u have a small maximum u can use an inline array
and use that
generally u shouldnt use unbound stack allocations.
constants are safe and fast
dynamic and bound to an upper limit are safe but not that fast.
dynamic and unbound is not that fast and dangerous.
so if u go over some maximum, u should either allocate an array or use an array pool as fallback
or just
didnt know that, tho i would still go with the buffer apprach than with this mess >.<
well that uses an inlinearray
i wish there was some syntax for it
seems like this does as well, and even has a lot of assignments for that:
https://sharplab.io/#v2:D4AQTAjAsAUCDMACciDCiDetE+UkALIgLIAUAlJtrjQMoAOAhgHYA8pA9gEYBWApgGMALgBpkEAAzkAfIgDOiALyIA2gBM+AM0YBXADajEG7fsPHdBsedNWtFs3ZtHHl5ydfWPLh+5/3bvgH+bsGeQgC6ANzUOAC+sLFAA==
SharpLab
C#/VB/F# compiler playground.
yeah I've meant my versioon
hmm with the assignments
maybe somebody should open a #roslyn issue
to skip assigning with default