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

Use DATAPTR_OR_NULL() in ExtractSubset() when possible #176

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

DavisVaughan
Copy link

@DavisVaughan DavisVaughan commented Jul 13, 2024

Copy link

@krlmlr krlmlr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! Spaces vs. tabs isn't super-clean everywhere, but let's wait for the Bugzilla feedback once it's there.

Comment on lines 148 to 151
EXTRACT_SUBSET_LOOP(const int* px = (const int*) DATAPTR_OR_NULL(x),
LOGICAL0(result)[i] = px[ii],
LOGICAL0(result)[i] = LOGICAL_ELT(x, ii),
LOGICAL0(result)[i] = NA_LOGICAL);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if something along the following lines would work too, with a suitable implementation above:

Suggested change
EXTRACT_SUBSET_LOOP(const int* px = (const int*) DATAPTR_OR_NULL(x),
LOGICAL0(result)[i] = px[ii],
LOGICAL0(result)[i] = LOGICAL_ELT(x, ii),
LOGICAL0(result)[i] = NA_LOGICAL);
EXTRACT_SUBSET_LOOP(const int* px = (const int*) DATAPTR_OR_NULL(x),
SET_LOGICAL_ELT, LOGICAL_ELT, NA_LOGICAL);

SET_LOGICAL_ELT() could be defined as a macro, like in src/main/saveload.c .

@DavisVaughan DavisVaughan force-pushed the feature/extract-subset-dataptr-or-null branch from 0edaded to 772089c Compare July 16, 2024 17:00
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 this pull request may close these issues.

2 participants