3 ms·
I doubt it'll be that bad. This new behavior is how .NET has done it all along, and out of all the mountains of code I've written that loop over the words in a
by bunderbunder 13y ago
I doubt it'll be that bad. This new behavior is how .NET has done it all along, and out of all the mountains of code I've written that loop over the words in a block of text I've found exactly one situation where benchmarks showed it was worth worrying about. Not for lack of looking, either.
I'm inclined to think that Java's old way of doing it is an optimization that largely became obsolete when the HotSpot VM came out over a decade ago. The nature of generational garbage collection means that the way this method ends up using memory in practice is rather different from what one might expect at first glance. Combine that with modern CPU architecture and it might even end up being faster because of better cache-friendliness.