Is there anything I should consider?
RayLivingston:
You do realize, using a linked list, beyond a certain number of elements it will certainly be considerable slower to parse the list than the original array. With only a few elements in the array it will likely be faster, but I suspect by the time the list is perhaps 1/4 filled, it will be slower, and when full it will be MUCH slower than it is now. And each time you add or remove or move elements in the list it will be MUCH slower, since you'll have to go through malloc, which has to walk the free memory list. If you want fast, dynamic allocation is NOT the way to go.Most likely, the correct/best answer to your problem was given above - pack eight values into a byte, or 32 into an unsigned int since you're on an ESP. You can then test for all true, or all false or any other desired pattern in each byte or int with a single compare operation.
But, again, since you don't allow us to know what you're really DOING with the data, nobody here can really say what the best answer is with any certainty. We can only guess based on the limited information you've provided.
What I'm doing with the data? I'm trying to reduce overhead that is contributing to the slowdown of linear fade steps in a non-blocking fade function. I don't expect anyone to give me an answer with certainty, I don't want anyone to write code for me or do any kind of work for me. I'm only asking a general question about programming in C.
Thank you for the information on using bytes and perspective on the dynamic lists, I appreciate it. I'll give it a try.
Dr-Zee:
What I'm doing with the data? I'm trying to reduce overhead that is contributing to the slowdown of linear fade steps in a non-blocking fade function.
"overhead" is largely a function of EXACTLY what you're doing with the data. It is IMPOSSIBLE to optimize algorithms and data structures for a single parameter without understanding everything that those structures and algorithms need to accomplish, and the constraints under which they operate. Since you are not willing to divulge those deep, dark secrets, you now have a bunch of generic answers, every one of which may be wrong, and may well make things worse, rather than better.
Good luck! I think you're going to need it.
This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.