Big Chungus
Big Chungus
CC#
Created by Big Chungus on 2/20/2025 in #help
Object passed by reference unexpectedly
Why is the context of a modified when context is modified?
c#
TokenContext context = new TokenContext(0,1,0,0,src); // start = 0
Token a = new Token(new SortedSet<int>{0,1}, new List<Token>{}, context);
context.start = 1;
context.end = 2;
Token b = new Token(new SortedSet<int>{1,2}, new List<Token>{}, context);
Console.WriteLine(a.context.start); // 1
Console.WriteLine(b.context.start); // 1
c#
TokenContext context = new TokenContext(0,1,0,0,src); // start = 0
Token a = new Token(new SortedSet<int>{0,1}, new List<Token>{}, context);
context.start = 1;
context.end = 2;
Token b = new Token(new SortedSet<int>{1,2}, new List<Token>{}, context);
Console.WriteLine(a.context.start); // 1
Console.WriteLine(b.context.start); // 1
39 replies
CC#
Created by Big Chungus on 2/4/2025 in #help
Fast regex that takes in a span instead of a string
I'm trying to port a lexer I wrote in c++ to c# and want to get the same functionality as RE2's consume method, however it seems like all the c# wrappers for RE2 don't even support using ReadOnlySpan<char> instead of strings as input, which seems like it would be ludicrously slow when ran repeatedly compared to using a ReadOnlySpan<char> (or equivalent to c++'s string_view). Is there a way around this or am I forced to suffer through slow code?
44 replies