memoise
memoise copied to clipboard
sort evaluated arguments in formals' order to ensure cache hit
when the function has multiple default arguments or the default argument is not defined at the end of formal list, whether the default values are passed explicitly (by call) or implicitly (by default mechanism) may matter
fn <- function(x = 1, y = 1)
fm <- memoise(fn)
fm(x = 1)
fm(y = 1)
the last 2 call are essentially same, but would have called fn
twice. that is because default values are attached to args
ignoring their order in formals. sort them in original order would solve this.
Codecov Report
Merging #89 into master will decrease coverage by
16.24%
. The diff coverage is100%
.
@@ Coverage Diff @@
## master #89 +/- ##
===========================================
- Coverage 77.37% 61.13% -16.25%
===========================================
Files 5 5
Lines 221 229 +8
===========================================
- Hits 171 140 -31
- Misses 50 89 +39
Impacted Files | Coverage Δ | |
---|---|---|
R/memoise.R | 100% <100%> (ø) |
:arrow_up: |
R/cache_s3.R | 0% <0%> (-100%) |
:arrow_down: |
Continue to review full report at Codecov.
Legend - Click here to learn more
Δ = absolute <relative> (impact)
,ø = not affected
,? = missing data
Powered by Codecov. Last update 1650ad7...281c540. Read the comment docs.