Skip to content

Commit

Permalink
kernel: add NEW_BLIST (#5774)
Browse files Browse the repository at this point in the history
  • Loading branch information
fingolfin authored Aug 21, 2024
1 parent 414a824 commit ff7537c
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 9 deletions.
10 changes: 3 additions & 7 deletions src/blister.c
Original file line number Diff line number Diff line change
Expand Up @@ -431,8 +431,7 @@ static Obj ElmsBlist(Obj list, Obj poss)
lenPoss = LEN_LIST( poss );

// make the result list
elms = NewBag( T_BLIST, SIZE_PLEN_BLIST( lenPoss ) );
SET_LEN_BLIST( elms, lenPoss );
elms = NEW_BLIST( lenPoss );

// loop over the entries of <positions> and select
block = 0; bit = 1;
Expand Down Expand Up @@ -492,8 +491,7 @@ static Obj ElmsBlist(Obj list, Obj poss)
}

// make the result list
elms = NewBag( T_BLIST, SIZE_PLEN_BLIST( lenPoss ) );
SET_LEN_BLIST( elms, lenPoss );
elms = NEW_BLIST(lenPoss);

if (inc == 1) {
CopyBits(CONST_BLOCKS_BLIST(list) + ((pos - 1) / BIPEB),
Expand Down Expand Up @@ -1099,9 +1097,7 @@ static Obj FuncBLIST_LIST(Obj self, Obj list, Obj sub)
RequireSmallList(SELF_NAME, list);
RequireSmallList(SELF_NAME, sub);

Int lenList = LEN_LIST( list );
Obj blist = NewBag( T_BLIST, SIZE_PLEN_BLIST( lenList ) );
SET_LEN_BLIST(blist, lenList);
Obj blist = NEW_BLIST(LEN_LIST(list));

FuncUNITE_BLIST_LIST(self, list, blist, sub);

Expand Down
15 changes: 15 additions & 0 deletions src/blister.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,21 @@ EXPORT_INLINE void SET_LEN_BLIST(Obj list, Int len)
}


/****************************************************************************
**
*F NEW_BLIST( <len> ) . . . . . . . create new boolean list with given len
**
** returns a new blist with <len> entries, all equal to 'false'.
**
*/
EXPORT_INLINE Obj NEW_BLIST(Int len)
{
Obj blist;
blist = NewBag(T_BLIST, SIZE_PLEN_BLIST(len));
SET_LEN_BLIST(blist, len);
return blist;
}

/****************************************************************************
**
*F BLOCKS_BLIST( <list> ) . . . . . . . . . . first block of a boolean list
Expand Down
3 changes: 1 addition & 2 deletions src/listfunc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1422,8 +1422,7 @@ static Obj FuncLIST_WITH_IDENTICAL_ENTRIES(Obj self, Obj n, Obj obj)
memset(CHARS_STRING(list), CHAR_VALUE(obj), len);
}
else if (obj == True || obj == False) {
list = NewBag(T_BLIST, SIZE_PLEN_BLIST(len));
SET_LEN_BLIST(list, len);
list = NEW_BLIST(len);
if (obj == True) {
UInt * ptrBlist = BLOCKS_BLIST(list);
for (; len >= BIPEB; len -= BIPEB)
Expand Down

0 comments on commit ff7537c

Please sign in to comment.