Jump to content

Question concerning "case"


HighGuy
 Share

Recommended Posts

Hi,

I'm using a "select..case..endselect" with a lot of case-expressions. I have the feeling, that if I add more and more "cases" the slower my app gets even if the matching case is at the beginning. The help file tells me that only the first matching case will be executed. Does this behavior include that all the other cases won't be "processed" afterwards? At the moment I suppose they will which is unnecessary in my opinion. Is this true?

Link to comment
Share on other sites

  • Administrators

Hi,

I'm using a "select..case..endselect" with a lot of case-expressions. I have the feeling, that if I add more and more "cases" the slower my app gets even if the matching case is at the beginning. The help file tells me that only the first matching case will be executed. Does this behavior include that all the other cases won't be "processed" afterwards? At the moment I suppose they will which is unnecessary in my opinion. Is this true?

I'm pretty sure that oncethe matching case has been matched it jumps directly to the endselect statement so no penalty there. However it does test each case up to the matching case - so the further down the list the matching case is the slower it is.

Link to comment
Share on other sites

I'm pretty sure that oncethe matching case has been matched it jumps directly to the endselect statement so no penalty there. However it does test each case up to the matching case - so the further down the list the matching case is the slower it is.

As often, you're right Jon. I did some more testing and changed order of my case-expressions. Of course it took some time longer if I put them down the list. But I had one entry at the top that took quite a long time to "react" and that was the exit-function of my GUI. In that function I use GUIDelete() to clean it up and as I have a really big GUI with lots of controls that took a very long time. If I only use "exit" it terminates immediately. What stays is that the CPU is using a lot of "time" while doing nothing and I do not know where this load is coming from. GuiGetMsg()?

Thank you for your help!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...