Slacker News Slacker News logo featuring a lazy sloth with a folded newspaper hat
  • top
  • new
  • show
  • ask
  • jobs
Library
← Back to context

Comment by gpderetta

1 hour ago

https://en.wikipedia.org/wiki/Loop_unswitching

1 comment

gpderetta

Reply

econ  30 minutes ago

    bool w;
    int x[1000];
    int y[1000];
    for(int i=0;i<1000;i++){
      x[i] += y[i];
    }
    if(w){
      for(int i=0;i<1000;i++){
        y[i] = 0;
      }
    }

Slower but prettier with the if pushed down.

Slacker News

Product

  • API Reference
  • Hacker News RSS
  • Source on GitHub

Community

  • Support Ukraine
  • Equal Justice Initiative
  • GiveWell Charities