Bug 5036 – Remove caching from ranges

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
Other
OS
All
Creation time
2010-10-10T14:38:00Z
Last change time
2015-02-18T03:41:01Z
Assigned to
peter.alexander.au
Creator
tomeksowi

Comments

Comment #0 by tomeksowi — 2010-10-10T14:38:28Z
All higher-order ranges in Phobos should not cache their element values. Such known ranges are: std.algorithm.Map and std.range.Sequence. A Cached range should be introduced to make up for the loss.
Comment #1 by andrei — 2013-02-26T08:56:37Z
Hm, I think things are fine as they are, though I agree with the consistency argument. Agree to close?
Comment #2 by tomeksowi — 2013-02-26T12:28:04Z
The argument was the least about consistency, I recall caching got in the way when the mapped to element was: - used <= 1 times - trivial to calculate (faster than read/write) - manually allocated (harder to anticipate destruction) Plus, front/back vs. opIndex poses problems of their own. Why the obligation to cache?
Comment #3 by hsteoh — 2014-11-17T03:06:51Z
Does this problem still occur? Over the last little while, many ranges have been rewritten to not cache their elements by default (unless there was reason to do so). Are there any specific ranges that cache .front in a problematic way? If not, can we close this bug?
Comment #4 by dmitry.olsh — 2014-11-17T20:58:06Z
Sequence still has cache, I'm not sure to what extent it's a problem.
Comment #5 by peter.alexander.au — 2015-01-02T10:52:26Z
Comment #6 by github-bugzilla — 2015-01-03T07:49:28Z
Commits pushed to master at https://github.com/D-Programming-Language/phobos https://github.com/D-Programming-Language/phobos/commit/8bb453a983d97da27454d96875cd5c574a72241d Fix Issue 5036 - Remove caching from Sequence This appears to be the last caching range in Phobos. This is a potentially breaking change: we lose the ability to moveFront, and obviously there may be performance implications if the function is expensive and users are calling front more than once. I think this is still a worthwhile change since it is better to have a uniform policy of no caching on ranges rather than arbitrary selection of ranges that do caching. https://issues.dlang.org/show_bug.cgi?id=5036 https://github.com/D-Programming-Language/phobos/commit/76504e6e2eaf28517a0385fcbbe2e22d1c06f710 Merge pull request #2834 from Poita/Issue5036 Fix Issue 5036 - Remove caching from Sequence
Comment #7 by github-bugzilla — 2015-02-18T03:41:01Z