digitalmars.D.bugs - [Issue 15162] New: byDchar calls empty twice in a row
- via Digitalmars-d-bugs (43/43) Oct 05 2015 https://issues.dlang.org/show_bug.cgi?id=15162
https://issues.dlang.org/show_bug.cgi?id=15162 Issue ID: 15162 Summary: byDchar calls empty twice in a row Product: D Version: D2 Hardware: All OS: All Status: NEW Severity: enhancement Priority: P1 Component: phobos Assignee: nobody puremagic.com Reporter: bugzilla digitalmars.com The following program: import std.utf; import core.stdc.stdio; struct S { bool empty() { printf("empty\n"); return !s.length; } property char front() { printf("front\n"); return s[0]; } void popFront() { printf("popFront()\n"); s = s[1 .. $]; } string s; } void main() { auto s = S("hello"); auto r = s.byDchar(); r.empty; r.front; r.popFront(); r.empty; r.front; r.popFront(); } prints 'empty' twice: empty empty front popFront() empty empty front popFront() For efficiency, it should only call empty once per character. --
Oct 05 2015