Skip to content

Commit

Permalink
ceylon/ceylon-compiler#2130: Avoid using current++ in Measure.iterato…
Browse files Browse the repository at this point in the history
…r because in the case where ++ throws it complicates optimization to a C-style for loop.
  • Loading branch information
tombentley committed Jun 16, 2015
1 parent 4b0d12c commit e5117a4
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/ceylon/language/Measure.ceylon
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,17 @@ class Measure<Element>(first, size)
=> object satisfies Iterator<Element> {
variable value count = 0;
variable value current = first;
next() => ++count > size
then finished else current++;
shared actual Element|Finished next() {
//++count > size
// then finished else current++;
if (count >= size) {
return finished;
} else if (count++ == 0) {
return current;
} else {
return ++current;
}
}
string => "(``outer.string``).iterator()";
};

Expand Down

0 comments on commit e5117a4

Please sign in to comment.