Click here to Skip to main content
15,886,963 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.

 
GeneralRe: In .NET enumeration is slow Pin
Graeme_Grant18-Jan-24 13:03
mvaGraeme_Grant18-Jan-24 13:03 
GeneralRe: In .NET enumeration is slow Pin
honey the codewitch18-Jan-24 13:07
mvahoney the codewitch18-Jan-24 13:07 
GeneralRe: In .NET enumeration is slow Pin
Graeme_Grant18-Jan-24 13:16
mvaGraeme_Grant18-Jan-24 13:16 
GeneralRe: In .NET enumeration is slow Pin
honey the codewitch18-Jan-24 13:22
mvahoney the codewitch18-Jan-24 13:22 
GeneralRe: In .NET enumeration is slow Pin
Graeme_Grant18-Jan-24 13:44
mvaGraeme_Grant18-Jan-24 13:44 
GeneralRe: In .NET enumeration is slow Pin
honey the codewitch18-Jan-24 13:49
mvahoney the codewitch18-Jan-24 13:49 
GeneralRe: In .NET enumeration is slow Pin
Graeme_Grant18-Jan-24 13:58
mvaGraeme_Grant18-Jan-24 13:58 
GeneralRe: In .NET enumeration is slow Pin
honey the codewitch18-Jan-24 14:04
mvahoney the codewitch18-Jan-24 14:04 
That's actually targeting Microsoft's .NET 7 implementation, and yeah I've looked at their source generator and considered making my own using the same tech. Right now I'm using the CodeDOM for that, which is older, but doesn't require near as much buy in in terms of your install base. For instance, you don't need compiler services running, and I'm not even sure how compatible it is with DNF and there are other unknowns. I need to do more research.

I actually did dotNetPeek them which is how I figured out the Span stuff. I don't like their code. Frankly, I'm impressed with the code-synthesis but they still made it hard to follow, and I'm not sure if that's so beneficial. My code looks machine generated, but it's easy to follow, as state machines go:

C#
// Matches C line comments or block comments
private FAMatch _BlockEnd0(ReadOnlySpan<char> s, int cp, int len, int position, int line, int column) {
q0:
    // [\*]
    if ((cp == 42)) {
        this.Advance(s, ref cp, ref len, false);
        goto q1;
    }
    goto errorout;
q1:
    // [\/]
    if ((cp == 47)) {
        this.Advance(s, ref cp, ref len, false);
        goto q2;
    }
    goto errorout;
q2:
    return FAMatch.Create(0, s.Slice(position, len).ToString(), position, line, column);
errorout:
    if ((cp == -1)) {
        return FAMatch.Create(-1, s.Slice(position, len).ToString(), position, line, column);
    }
    this.Advance(s, ref cp, ref len, false);
    goto q0;
}
private FAMatch NextMatchImpl(ReadOnlySpan<char> s) {
    int ch;
    int len;
    int p;
    int l;
    int c;
    ch = -1;
    len = 0;
    if ((this.position == -1)) {
        this.position = 0;
    }
    p = this.position;
    l = this.line;
    c = this.column;
    this.Advance(s, ref ch, ref len, true);
    // q0:
    // [\/]
    if ((ch == 47)) {
        this.Advance(s, ref ch, ref len, false);
        goto q1;
    }
    goto errorout;
q1:
    // [\*]
    if ((ch == 42)) {
        this.Advance(s, ref ch, ref len, false);
        goto q2;
    }
    goto errorout;
q2:
    return _BlockEnd0(s, ch, len, p, l, c);
errorout:
    if (((ch == -1) 
                || (ch == 47))) {
        if ((len == 0)) {
            return FAMatch.Create(-2, null, 0, 0, 0);
        }
        return FAMatch.Create(-1, s.Slice(p, len).ToString(), p, l, c);
    }
    this.Advance(s, ref ch, ref len, false);
    goto errorout;
}


Main thing that makes it tough is the use of UTF-32 codepoints instead of chars - necessary for surrogate handling in a seamless manner. I originally used char literals for the transitions but that was incompatible with VB.NET source generation. Frankly, VB.NET is an utter curmudgeon in terms of what it will accept and I hate creating language agnostic code templates that can target it. I always ALWAYS have to massage them for VB.NET. Mad | :mad:
Check out my IoT graphics library here:
https://honeythecodewitch.com/gfx
And my IoT UI/User Experience library here:
https://honeythecodewitch.com/uix

GeneralRe: In .NET enumeration is slow Pin
Graeme_Grant18-Jan-24 14:28
mvaGraeme_Grant18-Jan-24 14:28 
GeneralRe: In .NET enumeration is slow Pin
honey the codewitch18-Jan-24 14:29
mvahoney the codewitch18-Jan-24 14:29 
GeneralRe: In .NET enumeration is slow Pin
honey the codewitch18-Jan-24 14:09
mvahoney the codewitch18-Jan-24 14:09 
GeneralRe: In .NET enumeration is slow Pin
obermd19-Jan-24 3:47
obermd19-Jan-24 3:47 
GeneralRe: In .NET enumeration is slow Pin
Andy Brummer19-Jan-24 6:17
sitebuilderAndy Brummer19-Jan-24 6:17 
GeneralAnd so this is just a problem there? Pin
jschell18-Jan-24 5:28
jschell18-Jan-24 5:28 
GeneralRe: And so this is just a problem there? Pin
Gerry Schmitz18-Jan-24 7:18
mveGerry Schmitz18-Jan-24 7:18 
GeneralRe: And so this is just a problem there? Pin
Bruno van Dooren18-Jan-24 20:24
mvaBruno van Dooren18-Jan-24 20:24 
GeneralMS can't catch a break when it comes to search PinPopular
dandy7218-Jan-24 5:04
dandy7218-Jan-24 5:04 
GeneralRe: MS can't catch a break when it comes to search Pin
PIEBALDconsult18-Jan-24 5:08
mvePIEBALDconsult18-Jan-24 5:08 
GeneralRe: MS can't catch a break when it comes to search Pin
dandy7218-Jan-24 5:43
dandy7218-Jan-24 5:43 
GeneralRe: MS can't catch a break when it comes to search Pin
David O'Neil18-Jan-24 6:55
professionalDavid O'Neil18-Jan-24 6:55 
QuestionRe: MS can't catch a break when it comes to search Pin
fgs196318-Jan-24 7:36
fgs196318-Jan-24 7:36 
GeneralRe: MS can't catch a break when it comes to search Pin
snorkie18-Jan-24 5:46
professionalsnorkie18-Jan-24 5:46 
GeneralRe: MS can't catch a break when it comes to search Pin
David O'Neil18-Jan-24 7:00
professionalDavid O'Neil18-Jan-24 7:00 
GeneralRe: MS can't catch a break when it comes to search Pin
snorkie18-Jan-24 8:04
professionalsnorkie18-Jan-24 8:04 
GeneralRe: MS can't catch a break when it comes to search Pin
David O'Neil18-Jan-24 8:41
professionalDavid O'Neil18-Jan-24 8:41 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.