-
Notifications
You must be signed in to change notification settings - Fork 30
Eliminate ATTRIB() use
#87
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
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| [ | ||
| { | ||
| "command": "clang++ -arch arm64 -std=gnu++17 -I\"/Library/Frameworks/R.framework/Versions/4.5-arm64/Resources/include\" -DNDEBUG -I\"/Users/hadleywickham/Library/R/arm64/4.5/library/cpp11/include\" -I/opt/R/arm64/include -fPIC -falign-functions=64 -Wall -g -O2 -c address.cpp -o address.o", | ||
| "file": "address.cpp", | ||
| "directory": "/Users/hadleywickham/Documents/r-lib/lobstr/src" | ||
| }, | ||
| { | ||
| "command": "clang++ -arch arm64 -std=gnu++17 -I\"/Library/Frameworks/R.framework/Versions/4.5-arm64/Resources/include\" -DNDEBUG -I\"/Users/hadleywickham/Library/R/arm64/4.5/library/cpp11/include\" -I/opt/R/arm64/include -fPIC -falign-functions=64 -Wall -g -O2 -c cpp11.cpp -o cpp11.o", | ||
| "file": "cpp11.cpp", | ||
| "directory": "/Users/hadleywickham/Documents/r-lib/lobstr/src" | ||
| }, | ||
| { | ||
| "command": "clang++ -arch arm64 -std=gnu++17 -I\"/Library/Frameworks/R.framework/Versions/4.5-arm64/Resources/include\" -DNDEBUG -I\"/Users/hadleywickham/Library/R/arm64/4.5/library/cpp11/include\" -I/opt/R/arm64/include -fPIC -falign-functions=64 -Wall -g -O2 -c inspect.cpp -o inspect.o", | ||
| "file": "inspect.cpp", | ||
| "directory": "/Users/hadleywickham/Documents/r-lib/lobstr/src" | ||
| }, | ||
| { | ||
| "command": "clang++ -arch arm64 -std=gnu++17 -I\"/Library/Frameworks/R.framework/Versions/4.5-arm64/Resources/include\" -DNDEBUG -I\"/Users/hadleywickham/Library/R/arm64/4.5/library/cpp11/include\" -I/opt/R/arm64/include -fPIC -falign-functions=64 -Wall -g -O2 -c size.cpp -o size.o", | ||
| "file": "size.cpp", | ||
| "directory": "/Users/hadleywickham/Documents/r-lib/lobstr/src" | ||
| } | ||
| ] | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -83,8 +83,25 @@ double obj_size_tree(SEXP x, | |
| #endif | ||
|
|
||
| // CHARSXPs have fake attributes | ||
| if (TYPEOF(x) != CHARSXP ) | ||
| size += obj_size_tree(ATTRIB(x), base_env, sizeof_node, sizeof_vector, seen, depth + 1); | ||
| if (TYPEOF(x) != CHARSXP && ANY_ATTRIB(x)) { | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Now that we have
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good idea! |
||
| struct attrib_size_data { | ||
| double* size; | ||
| SEXP base_env; | ||
| int sizeof_node; | ||
| int sizeof_vector; | ||
| std::set<SEXP>* seen; | ||
| int depth; | ||
| }; | ||
| attrib_size_data cb_data = {&size, base_env, sizeof_node, sizeof_vector, &seen, depth}; | ||
| R_mapAttrib(x, [](SEXP tag, SEXP val, void* data) -> SEXP { | ||
| attrib_size_data* d = (attrib_size_data*)data; | ||
| // Account for the pairlist cons cell | ||
| *(d->size) += d->sizeof_node; | ||
| *(d->size) += obj_size_tree(tag, d->base_env, d->sizeof_node, d->sizeof_vector, *(d->seen), d->depth + 1); | ||
| *(d->size) += obj_size_tree(val, d->base_env, d->sizeof_node, d->sizeof_vector, *(d->seen), d->depth + 1); | ||
| return NULL; | ||
| }, &cb_data); | ||
| } | ||
|
|
||
| switch (TYPEOF(x)) { | ||
| // Vectors ------------------------------------------------------------------- | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -66,7 +66,7 @@ | |
| Output | ||
| [1] <INTSXP[10]> (altrep ) | ||
| _class [2] <RAWSXP[144]> () | ||
| _attrib [3] <LISTSXP> () | ||
| _attrib [3] <VECSXP[3]> () | ||
|
||
| [4] <SYMSXP: compact_intseq> () | ||
| [5] <SYMSXP: base> () | ||
| [6] <INTSXP[1]> () | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Am I supposed to gitignore this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep these commands are specific to your setup