Skip to content

optimizations for pickapart and repr_l fix for large lists #4

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions xxl.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ char* repr_c(VP x,char* s,size_t sz) {
int i=0,n=x->n,ch;
FMT_into_s(sz,"\"",0);
for(;i<n;i++){
if(REPR_MAX_ITEMS && i==(REPR_MAX_ITEMS/2)) {
FMT_into_s(sz,".. (%d omitted) ..", n-REPR_MAX_ITEMS);
break;
}
ch = AS_c(x,i);
if(ch=='"') FMT_into_s(sz,"\\\"", 0);
else if(ch=='\n') FMT_into_s(sz,"\\n", 0);
Expand Down Expand Up @@ -140,8 +144,7 @@ char* repr_l(VP x,char* s,size_t sz) {
for(i=0;i<n;i++){
if(REPR_MAX_ITEMS && i==(REPR_MAX_ITEMS/2)) {
FMT_into_s(sz,".. (%d omitted) ..", n-REPR_MAX_ITEMS);
i+=REPR_MAX_ITEMS;
continue;
break;
}
a = ELl(x,i);
if (a==NULL) FMT_into_s(sz,"null",0);
Expand Down Expand Up @@ -2909,7 +2912,7 @@ VP pickapart(VP x,VP y) { // select items of x[0..n] where y[n]=1, and divide no
acc=xlsz(4);
VARY_EACHBOTHLIST(x,y,({
if(_y) {
if (!sub) sub=ALLOC_LIKE_SZ(x,x->n/2);
if (!sub) sub=ALLOC_LIKE_SZ(x,1);
sub=appendbuf(sub,(buf_t)&_x,1);
} else {
if (sub) { acc=append(acc,sub); xfree(sub); sub=NULL; }
Expand Down