Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Serializing and deserializing fastmap with no holes doesn't work right #27

Closed
wch opened this issue Dec 23, 2022 · 0 comments · Fixed by #28
Closed

Serializing and deserializing fastmap with no holes doesn't work right #27

wch opened this issue Dec 23, 2022 · 0 comments · Fixed by #28

Comments

@wch
Copy link
Member

wch commented Dec 23, 2022

A new fastmap filled with exactly 32 items will have no holes. When serialized and unserialized, the resulting object provides the wrong result for as_list():

x <- seq_len(32)
m <- fastmap()
m$mset(.list = setNames(x, as.character(x)))
m1 <- unserialize(serialize(m, NULL))

m1$as_list()
#> named list()

This is because of this line:

idxs <- seq_along(keys_)[-holes]

This line is supposed to remove the original vector with n_holes items removed. However, when n_holes is 0, then holes is a length-0 vector, and x[-integer(0)] will return an empty vector instead of what we want, which is just the original x unchanged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant