thanks for looking at the code. it's much appreciated.
QUOTE (David Arthur @ May 23 2010, 03:07 PM) <{POST_SNAPBACK}>
It's taking me a bit of time to get my mind around your code because it's so different from anything I do in MissionComputer
i code in too many languages, so I have a sort of international-english style.
QUOTE (David Arthur @ May 23 2010, 03:07 PM) <{POST_SNAPBACK}>
Store your system data in arrays, not dictionaries. Even if the actual value is a number, reading from a dictionary always involves extensive string parsing behind the scenes, which is slow.
ah, i didn't know that. a cocoa dictionary isn't much slower than an array.
QUOTE (David Arthur @ May 23 2010, 03:07 PM) <{POST_SNAPBACK}>
Declare all of your variables at the beginning of the method. A Dim statement that's inside a loop gets executed repeatedly, to no purpose. (As a general rule, don't put anything in a loop that doesn't need to be there.)
this is a bit of me thinking ahead of myself, and a bit of objective-c. i'll move them out and redim if necessary.
QUOTE (David Arthur @ May 23 2010, 03:07 PM) <{POST_SNAPBACK}>
Don't keep calling UBound(canvasBuffer) in your loops. Call it once at the beginning of the method, and then assign its value to a variable and use that for the rest of the method. (As a general rule, try to avoid doing the same calculation more than once per method.)
When you say 'while systIndex < fileReference.syst.Count', fileReference.Syst.Count is evaluated every time the loop repeats. Copy it into a local variable, and then compare systIndex with that.
ah, another objective-c nuance. i didn't realise these were actually calculated every time they are called. i thought it was a property. the 'ubound' makes sense, the 'count' doesn't. i think dictionary.count should just be a variable.
QUOTE (David Arthur @ May 23 2010, 03:07 PM) <{POST_SNAPBACK}>
Graphics.DrawString is slower than all the other drawing methods (as a general rule, anything involving strings is slow). Avoid drawing text when possible, and when it's absolutely necessary, do it all at once. MissionComputer renders the system names as an entirely separate stage, after all the circles and links have already been drawn.
good point. i'll add drawSystNames to the buffer loop.
QUOTE (David Arthur @ May 23 2010, 03:07 PM) <{POST_SNAPBACK}>
Using a timer to redraw the canvas really is unnecessary.
Currently, yes. thinking ahead again.
QUOTE (David Arthur @ May 23 2010, 03:07 PM) <{POST_SNAPBACK}>
the Paint event will fire whenever a redraw is needed.
how so? i have to call canvas.refresh to get paint to fire.
QUOTE (David Arthur @ May 23 2010, 03:07 PM) <{POST_SNAPBACK}>
What confuses me most is why canvasBuffer is an array.
This is when i merged the DA doublebuffer branch and the NC quadBuffer. It's an experiment mostly. i can theoretically define how many buffers i want, making a dynamicBuffer. The timer will help with this.
QUOTE (David Arthur @ May 23 2010, 03:07 PM) <{POST_SNAPBACK}>
Unless I'm missing something, your timer seems to append a whole new picture to it every time it executes, and making new pictures takes time. I would just make canvasBuffer a single Picture, say 'canvasBuffer = NewPicture(' etc. etc. when the programme opens and whenever the window is resized, and get rid of all the UBound(canvasBuffer) stuff.
I will test out the impact of creating a new picture. It's required for the dynamicBuffer. Perhaps I can create 1 newPicture, then copy it each time into the buffer array.
I'll make another branch with your suggestions.
This post has been edited by Tycho : 23 May 2010 - 10:41 PM