Skip to content

remove allocNAVector in melt for memory efficiency#5054

Merged
mattdowle merged 5 commits intomasterfrom
melt-narm-without-allocating-NA
Jun 26, 2021
Merged

remove allocNAVector in melt for memory efficiency#5054
mattdowle merged 5 commits intomasterfrom
melt-narm-without-allocating-NA

Conversation

@tdhock
Copy link
Copy Markdown
Member

@tdhock tdhock commented Jun 26, 2021

While hacking various improvements to melt recently, I noticed that there were un-necessary allocations of temporary vectors of missing values via allocNAVector, when there are missing input columns. In this PR I propose to make melt more memory efficient by replacing those temporary NA vectors with NULL/R_NilValue which serves as a signal to either (1) do nothing if na.rm=TRUE, or (2) use writeNA on the output vector if na.rm=FALSE. There are no changes to user-facing functionality, but hopefully melt should be more efficient when there are missing input columns.

@tdhock tdhock requested a review from mattdowle June 26, 2021 03:37
@mattdowle mattdowle added this to the 1.14.1 milestone Jun 26, 2021
@mattdowle mattdowle merged commit ed72e39 into master Jun 26, 2021
@mattdowle mattdowle deleted the melt-narm-without-allocating-NA branch June 26, 2021 16:11
@jangorecki jangorecki modified the milestones: 1.14.9, 1.15.0 Oct 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants