Click here to Skip to main content
15,887,135 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: Wordle 944 Pin
OriginalGriff18-Jan-24 20:26
mveOriginalGriff18-Jan-24 20:26 
GeneralRe: Wordle 944 Pin
StarNamer@work18-Jan-24 22:37
professionalStarNamer@work18-Jan-24 22:37 
GeneralRe: Wordle 944 - 4 4 me Pin
pkfox18-Jan-24 21:02
professionalpkfox18-Jan-24 21:02 
GeneralRe: Wordle 944 Pin
Sander Rossel18-Jan-24 21:41
professionalSander Rossel18-Jan-24 21:41 
GeneralRe: Wordle 944 Pin
GuyThiebaut18-Jan-24 22:43
professionalGuyThiebaut18-Jan-24 22:43 
GeneralRe: Wordle 944 Pin
Cp-Coder19-Jan-24 1:29
Cp-Coder19-Jan-24 1:29 
GeneralRe: Wordle 944 (3/6) Pin
Jeremy Falcon19-Jan-24 6:55
professionalJeremy Falcon19-Jan-24 6:55 
GeneralIn .NET enumeration is slow Pin
honey the codewitch18-Jan-24 7:52
mvahoney the codewitch18-Jan-24 7:52 
I just switched IEnumerable to IList and removed foreach (preferring for) and cut my execution time in my test from 65ms to about 45ms.

I've put a stripped down version of the code here. The first argument of each emphasized routine was IEnumerable<fa>, is now IList<fa> with no foreach.

This, ladies and gents, is why I don't like LINQ.

C#
// here this._fa is the target machine we will be parsing.
// parse this or otherwise build it and use it here.
IList<FA> initial = FA.FillEpsilonClosure(this._fa);
IList<FA> next = new List<FA>();
IList<FA> states = new List<FA>(initial);
// start out with an empty capture buffer
this.capture.Clear();
// first move:
if (this.current == -2)
{
    this.Advance();
}
// store the current position
long cursor_pos = this.position;
int line = this.line;
int column = this.column;
while(true) {
    // try to transition from states on
    // the current codepoint under the
    // cursor
    next.Clear();
    FA.FillMove(states, this.current, next);
    if (next.Count > 0)
    {
        // found at least one transition
        // capture the current
        // char, advance the input
        // position:
        this.Advance();
        // move to the next states
        states.Clear();
        FA.FillEpsilonClosure(next, states);
    } else {
        // no matching transition
        // is any current state accepting?
        int acc = FA.GetFirstAcceptSymbol(states);
        if(acc>-1) {
            // accept
            return FAMatch.Create(
                acc,
                this.capture.ToString(),
                cursor_pos,
                line,
                column);
        }
        // not accepting - error
        // keep capturing input until we find a 
        // valid move or there's no more input
        while (this.current != -1 &&
            FA.FillMove(initial, this.current).Count == 0)
        {
            this.Advance();
        }
        if (capture.Length == 0)
        {
            // end of input
            return FAMatch.Create(-2, null, 0, 0, 0);
        }
        // error
        return FAMatch.Create(-1,
            capture.ToString(),
            cursor_pos,
            line,
            column);
 
    }
}

Check out my IoT graphics library here:
https://honeythecodewitch.com/gfx
And my IoT UI/User Experience library here:
https://honeythecodewitch.com/uix


modified 18-Jan-24 14:01pm.

AnswerRe: In .NET enumeration is slow PinPopular
Eddy Vluggen18-Jan-24 8:04
professionalEddy Vluggen18-Jan-24 8:04 
GeneralRe: In .NET enumeration is slow PinPopular
honey the codewitch18-Jan-24 8:09
mvahoney the codewitch18-Jan-24 8:09 
GeneralRe: In .NET enumeration is slow Pin
Eddy Vluggen18-Jan-24 15:14
professionalEddy Vluggen18-Jan-24 15:14 
GeneralRe: In .NET enumeration is slow Pin
honey the codewitch18-Jan-24 15:39
mvahoney the codewitch18-Jan-24 15:39 
AnswerRe: In .NET enumeration is slow Pin
Eddy Vluggen18-Jan-24 16:05
professionalEddy Vluggen18-Jan-24 16:05 
GeneralRe: In .NET enumeration is slow Pin
honey the codewitch18-Jan-24 16:15
mvahoney the codewitch18-Jan-24 16:15 
GeneralRe: In .NET enumeration is slow Pin
Eddy Vluggen18-Jan-24 16:34
professionalEddy Vluggen18-Jan-24 16:34 
GeneralRe: In .NET enumeration is slow Pin
honey the codewitch18-Jan-24 17:00
mvahoney the codewitch18-Jan-24 17:00 
GeneralRe: In .NET enumeration is slow Pin
Eddy Vluggen19-Jan-24 1:21
professionalEddy Vluggen19-Jan-24 1:21 
GeneralRe: In .NET enumeration is slow Pin
honey the codewitch19-Jan-24 1:24
mvahoney the codewitch19-Jan-24 1:24 
GeneralRe: In .NET enumeration is slow Pin
MSBassSinger19-Jan-24 4:07
professionalMSBassSinger19-Jan-24 4:07 
GeneralRe: In .NET enumeration is slow Pin
jschell19-Jan-24 5:17
jschell19-Jan-24 5:17 
GeneralRe: In .NET enumeration is slow Pin
obermd19-Jan-24 3:44
obermd19-Jan-24 3:44 
GeneralRe: In .NET enumeration is slow Pin
trønderen19-Jan-24 5:44
trønderen19-Jan-24 5:44 
QuestionRe: In .NET enumeration is slow Pin
Eddy Vluggen18-Jan-24 15:54
professionalEddy Vluggen18-Jan-24 15:54 
GeneralRe: In .NET enumeration is slow Pin
englebart19-Jan-24 15:33
professionalenglebart19-Jan-24 15:33 
GeneralRe: In .NET enumeration is slow Pin
honey the codewitch19-Jan-24 16:07
mvahoney the codewitch19-Jan-24 16:07 

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.