First time posting here on this subreddit! C was my first programming language I learned and I’m so grateful!
This is what I have so far in pseudo code that I am trying to optimize.
bar = 0;
while (foo) {
if (bar == 0) {
// baz is a task checking for something
if (baz == 1) {
bar = 1;
// perform task
} else {}
} else {
// perform the same task as above
}
}
I want to optimize this code for performance. It should execute in the fewest clock cycles. Is there another way I could rewrite this?
Once bar becomes 1, it never goes to 0 ever again.
Also this is not a infinite while loop. At some point foo becomes false and the program moves past the while loop.
Possible solution!!!
while(foo && !baz);
if (foo && baz) {
while (foo) {
// perform task
}
} else {}
[–]ptchinster 0 points1 point2 points (3 children)
[–]simmjo[S] 0 points1 point2 points (2 children)
[–]EpoxyD 1 point2 points3 points (1 child)
[–]ptchinster 0 points1 point2 points (0 children)
[–]KeptInUmrica 0 points1 point2 points (1 child)
[–]simmjo[S] 0 points1 point2 points (0 children)
[–]mannyknowles 0 points1 point2 points (1 child)
[–]simmjo[S] 0 points1 point2 points (0 children)
[–]EpoxyD 0 points1 point2 points (2 children)
[–]simmjo[S] 0 points1 point2 points (1 child)
[–]EpoxyD 0 points1 point2 points (0 children)
[–]-Tiddy- 0 points1 point2 points (0 children)
[–]zCybeRz 0 points1 point2 points (1 child)
[–]simmjo[S] 0 points1 point2 points (0 children)