You'd think this would be faster, but NO!!!!!! [Resolved]
#12
(10-14-2022, 05:50 AM)Pete Wrote: Steve must have missed my second post.

Pete

I did, but it's amazing how similar we're thinking -- except, of course, you're once again thinking WRONG.  Tongue

Code: (Select All)
FOR i = 0 TO LEN(a.ship) - 1
    SELECT CASE SCREEN(j, k + i)
        CASE ASC(g.flagship)
            ii = 1
            EXIT FOR
        CASE g.m_asc
            ii = 2
    END SELECT
NEXT


I'd simplify this with one out of loop step, and then I wouldn't forget my EXIT and bug my code like you are:

Code: (Select All)
A = ASC(g.flagship) 'we do nothing to change the value of g.flagship in the loop.  Why do we need to calculate this value over and over repeatedly?
FOR i = k TO k + LEN(a.ship) - 1
    SELECT CASE SCREEN(j, i) 'no need to have a math operation here with each pass.  Do the math once in the FOR statement and be done with it.
        CASE A 'unchanging value of ASC(g.flagship) -- again, no need for multiple unchanging function calls to get this value.
            ii = 1
            EXIT FOR
        CASE g.m_asc
            ii = 2
            EXIT FOR 'Whoops!  Pete forgot the EXIT which the original had here.  
    END SELECT
NEXT


So now maybe Pete can see why I only ever read about half his posts and code -- at best, they're only about half as good as a Steve(tm) Post!  Big Grin
Reply


Messages In This Thread
RE: You'd think this would be faster, but NO!!!!!! - by SMcNeill - 10-14-2022, 07:57 AM



Users browsing this thread: 10 Guest(s)