Neocities.org

Thricegreat's Webpage

thricegreat.neocities.org

225,115 views
61 followers
3,776 updates
0 tips
>https://thricegreat.neocities.org/use_a_global_variable.txt When I first read this, I was unsure when this logic may be fruitful. I now understand. I recently wrote a couple functions that each need to iterate through their own constant character array. Initially, the array was declared every single time each function was called, which was less than ideal. For one of the functions, I bit the bullet
1 like
kaa 11 months ago

and passed the pointer through each of the functions between it and the function in question. It resulted in longer function definitions, and felt clumsy. For the couple other functions, I didn't want to do that, so I left them declaring their character arrays each time they were called. This bothered me, enough that I gave a simple declaration above the function definition a try instead. It worked well.

1 like
kaa 11 months ago

The program that once ran in roughly 0.2 seconds then ran in roughly 0.17 seconds. Both clumsiness and inefficiency were avoided, for the placement of the declaration above the function definition made the intent clear.

1 like
kaa 11 months ago

Reading this posting by you was what got me thinking about this problem in the first place. Thank you.

1 like
kaa 11 months ago

Linked is a copy of those two latter mentioned function definitions: https://kaa.neocities.org/Program/global.txt

1 like

Website Stats

Last updated 31 minutes ago
CreatedMar 20, 2022
Site Traffic Stats

Tags

technology math philosophy blog writing