Skip to main content
Tweeted twitter.com/StackArduino/status/1202648950462930944
edited tags
Link
VE7JRO
  • 2.5k
  • 19
  • 28
  • 31
edited tags
Link
asheeshr
  • 3.8k
  • 3
  • 26
  • 61
Source Link
Peter Bloomfield
  • 11k
  • 9
  • 48
  • 87

Would an infinite loop inside loop() perform faster?

When you're writing a typical sketch, you usually rely on loop() being called repeatedly for as long as the Arduino is running. Moving in and out of the loop() function must introduce a small overhead though.

To avoid that, you could presumably create your own infinite loop, like this:

void loop()
{
    while (true)
    {
        // do stuff...
    }
}

Is that a viable way to improve performance? Will it cause other problems if loop() never returns?