You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/caching_begin.md
+5-4Lines changed: 5 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -71,12 +71,13 @@ We want to find out how many times the predicate is evaluated when using the ada
71
71
| `for (size_t i : rad) {}` (2nd+) | 9 |
72
72
| `for (size_t i : rad │ radr::take(100)) {}` (comb.) | 9 |
73
73
74
-
This tables illustrates the differences and similarities between the standard library and our library:
74
+
This tables illustrates the similarities between the standard library and our library:
75
75
* Constructing the adaptor and iterating over it once adds up to 15 predicate calls.
76
76
* The second (and any further) iteration only performs 9 calls.
77
77
* Note that since neither `std` nor `radr` cache the end, the *last* five 1s will always be parsed. *More on this below*.
78
78
79
-
Finally, we see that the libraries differ when the adaptor is combined with another one, e.g. `take(100)`.
79
+
They differ in that some of the work happens on construction in RADR.
80
+
And finally, we see that the libraries differ when the adaptor is combined with another one, e.g. `take(100)`.
80
81
The standard library adaptor resets its cache when being moved or copied, because the caching mechanism in the standard library is *non-propagating*.
81
82
This is not known to most users of `std::ranges::`, and it is even more surprising since "building up" ranges pipelines in multiple steps is a frequently recommended practice.
82
83
@@ -95,11 +96,11 @@ In our library `radr::filter` is not common by default. This has the advantage t
| `for (size_t i : rad │ radr::take(100)) {}` (comb.) | 4 |
102
103
103
-
As you see, the range is parsed once completely on construction.
104
+
The head of the range is parsed on construction of `filter` (6 calls), and the tail is parsed on construction of `to_common` (reverse find, also 6 calls).
104
105
After this, the adaptor needs to parse neither the head, nor the tail of the underlying range on a full iteration.
105
106
The standard library does not offer such facilities.
0 commit comments