3 ms·
I know this was changed recently-ish in Java, but I hadn't heard of anybody doing the old substring trick in .NET, do you know when they cut over?
by kbsletten 9y ago
I know this was changed recently-ish in Java, but I hadn't heard of anybody doing the old substring trick in .NET, do you know when they cut over?
- kkokosa 9y agoThere is a lot of good things going on in .NET Core about this. Here is a good description of Span: http://adamsitnik.com/Span/#slicing-without-managed-heap-allocations http://adamsitnik.com/Span/#slicing-without-managed-heap-all...
- matthewwarren 9y agoAFAIK this trick was never possible in .NET because Substring always 'deep copied' the relevant data into a completely new string
- kevingadd 9y agoRegex's implementation in the standard library used to do this, and I think maybe still does. Bonus points because they leaked a reference to the last string you ran a regex against (????) so if it was big you'd just eat up 50 mb of heap for a while.