Using Spans to Improve Dot Net Runtime Parsing Performance

20 views
Skip to first unread message

John Sullivan

unread,
Jun 10, 2025, 9:33:13 AMJun 10
to antlr-discussion
I wanted to ask, if people think spans could be used to improve the performance of the Dot Net Runtime.
The reasoning would be that when parsing, rather than creating and destroying lots of small string or arrays as you parse a document, you could just use a span, that wouldn't need to allocate as much memory.

Harry Cordewener

unread,
Jun 10, 2025, 4:22:23 PMJun 10
to antlr-discussion
I've made some basic use of this in a few places for creating improved Token Streams and CharStreams  and the like, and it does improve performance a bit. 
But you have to pass input around by ReadOnlyMemory form to get there.

This is only relevant to Buffered streams in general however. 

What parts are you looking at, which is creating and destroying a lot of small strings and arrays?

Reply all
Reply to author
Forward
0 new messages