Skip to content

Commit

Permalink
blist: remove _UNSAFE variants of some macros
Browse files Browse the repository at this point in the history
Instead, just don't perform those extra TNUM checks. They are not
worth the hassle, at least for now.
  • Loading branch information
fingolfin committed Nov 28, 2017
1 parent 7c69681 commit c7037af
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 21 deletions.
4 changes: 2 additions & 2 deletions src/blister.c
Original file line number Diff line number Diff line change
Expand Up @@ -907,7 +907,7 @@ void PlainBlist (
/* replace the bits by 'True' or 'False' as the case may be */
/* this must of course be done from the end of the list backwards */
for ( i = len; 0 < i; i-- )
SET_ELM_PLIST(list, i, ELM_BLIST_UNSAFE(list, i));
SET_ELM_PLIST(list, i, ELM_BLIST(list, i));

/* 'CHANGED_BAG' not needed, 'True' and 'False' are safe */
}
Expand Down Expand Up @@ -992,7 +992,7 @@ void ConvBlist (
block |= bit;
bit = bit << 1;
if ( bit == 0 || i == len ) {
BLOCK_ELM_BLIST_UNSAFE(list, i) = block;
BLOCK_ELM_BLIST(list, i) = block;
block = 0;
bit = 1;
}
Expand Down
21 changes: 3 additions & 18 deletions src/blister.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,20 +131,13 @@ static inline void SET_LEN_BLIST(Obj list, Int len)
** returns a pointer to the start of the data of the Boolean list
**
*/
static inline UInt * BLOCKS_BLIST_UNSAFE(Obj list)
{
return ((UInt *)(ADDR_OBJ(list) + 1));
}

static inline UInt * BLOCKS_BLIST(Obj list)
{
GAP_ASSERT(IS_BLIST_REP_WITH_COPYING(list));
return BLOCKS_BLIST_UNSAFE(list);
return ((UInt *)(ADDR_OBJ(list) + 1));
}

static inline const UInt * CONST_BLOCKS_BLIST(Obj list)
{
GAP_ASSERT(IS_BLIST_REP_WITH_COPYING(list));
return ((const UInt *)(CONST_ADDR_OBJ(list) + 1));
}

Expand All @@ -161,8 +154,6 @@ static inline const UInt * CONST_BLOCKS_BLIST(Obj list)
** that have side effects.
*/
#define BLOCK_ELM_BLIST(list, pos) (BLOCKS_BLIST( list )[((pos)-1)/BIPEB])
#define BLOCK_ELM_BLIST_UNSAFE(list, pos) \
(BLOCKS_BLIST_UNSAFE(list)[((pos)-1) / BIPEB])


/****************************************************************************
Expand All @@ -188,7 +179,7 @@ static inline const UInt * CONST_BLOCKS_BLIST(Obj list)
*/
static inline Int TEST_BIT_BLIST(Obj list, UInt pos)
{
return BLOCK_ELM_BLIST_UNSAFE(list, pos) & MASK_POS_BLIST(pos);
return BLOCK_ELM_BLIST(list, pos) & MASK_POS_BLIST(pos);
}

/****************************************************************************
Expand All @@ -199,15 +190,9 @@ static inline Int TEST_BIT_BLIST(Obj list, UInt pos)
** either 'true' or 'false'. <pos> must be a positive integer less than or
** equal to the length of <list>.
*/
static inline Obj ELM_BLIST_UNSAFE(Obj list, UInt pos)
{
return TEST_BIT_BLIST(list, pos) ? True : False;
}

static inline Obj ELM_BLIST(Obj list, UInt pos)
{
GAP_ASSERT(IS_BLIST_REP_WITH_COPYING(list));
return ELM_BLIST_UNSAFE(list, pos);
return TEST_BIT_BLIST(list, pos) ? True : False;
}

/****************************************************************************
Expand Down
1 change: 0 additions & 1 deletion src/debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ VoidFunc debug_func_pointers[] = {
(VoidFunc)BAG_HEADER,
(VoidFunc)BASE_PTR_PLIST,
(VoidFunc)BLOCKS_BLIST,
(VoidFunc)BLOCKS_BLIST_UNSAFE,
(VoidFunc)BODY_FUNC,
(VoidFunc)BODY_HEADER,
(VoidFunc)C_MAKE_MED_INT,
Expand Down

0 comments on commit c7037af

Please sign in to comment.