memoise icon indicating copy to clipboard operation
memoise copied to clipboard

sort evaluated arguments in formals' order to ensure cache hit

Open bluaze opened this issue 5 years ago • 1 comments

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.

bluaze avatar May 10 '19 16:05 bluaze

Codecov Report

Merging #89 into master will decrease coverage by 16.24%. The diff coverage is 100%.

Impacted file tree graph

@@             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.

codecov-io avatar May 10 '19 16:05 codecov-io