Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

4
  • 3
    Not quite the same - that check happens once, instead of each iteration Commented Dec 9, 2013 at 16:36
  • @Izkata: Yes, that's a very good point! Commented Dec 9, 2013 at 16:44
  • 3
    if (i< MAX_VALUE_FOR_I) { loop-by-i; } looks slippery. Did you by chance mean if (len< MAX_VALUE_FOR_I)? Commented Dec 9, 2013 at 17:20
  • 2
    @gnat Even if so, the correct equivalent wouldn't prevent the loop from running, the OP's code limits the maximum iterations. To get the same effect: len = min(len, MAX_VALUE_FOR_I) Commented Dec 9, 2013 at 17:32