Jump to content

declaration inside SR_Service_Prepare()


protofuse
 Share

Recommended Posts

just a little question.

what is the most efficient option?

1/ variables globally declared and used in SR_Service_Prepare()

2/ variables locally declared inside SR_Service_Prepare() and used in SR_Service_Prepare()

I guess in the case 2/ each time the SR_Service_Prepare() is called, declarations eat cpu time ... right ?

so it may be the 1/ to choose

?!

Link to comment
Share on other sites

2) is the most efficient solution as it only allocates local stack (in zero time) - but take care that stack memory is limited (1024 bytes), don't declare huge arrays there

1) is expensive since it allocates RAM statically, and it's bad programming style - you want to avoid the usage of global variables whenever possible.

Best Regards, Thorsten.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...