Skip to content

Commit

Permalink
kernel: remove IS_MUTABLE_PLAIN_OBJ
Browse files Browse the repository at this point in the history
Just use IS_MUTABLE_OBJ directly; it has no overhead for internal objects,
and in all replaced cases, we know that the input is an internal object.
  • Loading branch information
fingolfin committed Nov 20, 2018
1 parent 624732f commit cbb5a73
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 39 deletions.
23 changes: 11 additions & 12 deletions src/blister.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,35 +113,34 @@ Obj TypeBlist(Obj list)
{
/* special case for the empty blist */
if ( LEN_BLIST(list) == 0 ) {
return IS_MUTABLE_PLAIN_OBJ(list) ? TYPE_BLIST_EMPTY_MUT
: TYPE_BLIST_EMPTY_IMM;
return IS_MUTABLE_OBJ(list) ? TYPE_BLIST_EMPTY_MUT
: TYPE_BLIST_EMPTY_IMM;
} else {
return IS_MUTABLE_PLAIN_OBJ(list) ? TYPE_BLIST_MUT
: TYPE_BLIST_IMM;
return IS_MUTABLE_OBJ(list) ? TYPE_BLIST_MUT : TYPE_BLIST_IMM;
}
}

Obj TypeBlistNSort(Obj list)
{
/* special case for the empty blist */
if ( LEN_BLIST(list) == 0 ) {
return IS_MUTABLE_PLAIN_OBJ(list) ? TYPE_BLIST_EMPTY_MUT
: TYPE_BLIST_EMPTY_IMM;
return IS_MUTABLE_OBJ(list) ? TYPE_BLIST_EMPTY_MUT
: TYPE_BLIST_EMPTY_IMM;
} else {
return IS_MUTABLE_PLAIN_OBJ(list) ? TYPE_BLIST_NSORT_MUT
: TYPE_BLIST_NSORT_IMM;
return IS_MUTABLE_OBJ(list) ? TYPE_BLIST_NSORT_MUT
: TYPE_BLIST_NSORT_IMM;
}
}

Obj TypeBlistSSort(Obj list)
{
/* special case for the empty blist */
if ( LEN_BLIST(list) == 0 ) {
return IS_MUTABLE_PLAIN_OBJ(list) ? TYPE_BLIST_EMPTY_MUT
: TYPE_BLIST_EMPTY_IMM;
return IS_MUTABLE_OBJ(list) ? TYPE_BLIST_EMPTY_MUT
: TYPE_BLIST_EMPTY_IMM;
} else {
return IS_MUTABLE_PLAIN_OBJ(list) ? TYPE_BLIST_SSORT_MUT
: TYPE_BLIST_SSORT_IMM;
return IS_MUTABLE_OBJ(list) ? TYPE_BLIST_SSORT_MUT
: TYPE_BLIST_SSORT_IMM;
}
}

Expand Down
1 change: 0 additions & 1 deletion src/debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,6 @@ VoidFunc debug_func_pointers[] = {
(VoidFunc)IS_MODULE_DYNAMIC,
(VoidFunc)IS_MODULE_STATIC,
(VoidFunc)IS_MUTABLE_OBJ,
(VoidFunc)IS_MUTABLE_PLAIN_OBJ,
(VoidFunc)IS_NEG_INT,
(VoidFunc)IS_NONNEG_INTOBJ,
(VoidFunc)IS_ODD_INT,
Expand Down
16 changes: 0 additions & 16 deletions src/objects.h
Original file line number Diff line number Diff line change
Expand Up @@ -577,22 +577,6 @@ static inline Int IS_MUTABLE_OBJ(Obj obj)
}


/****************************************************************************
**
*F IS_MUTABLE_PLAIN_OBJ( <obj> ) . . . . . . is an object plain and mutable
**
** 'IS_MUTABLE_PLAIN_OBJ' returns 1 if the object <obj> is a plain object
** (i.e., built into GAP), and mutable (i.e., can change due to assignments),
** and 0 otherwise.
*/
static inline Int IS_MUTABLE_PLAIN_OBJ(Obj obj)
{
UInt type = TNUM_OBJ(obj);
return (FIRST_IMM_MUT_TNUM <= type) && (type <= LAST_IMM_MUT_TNUM)
&& !(type & IMMUTABLE);
}


/****************************************************************************
**
*F IsInternallyMutableObj( <obj> ) . . . does an object have a mutable state
Expand Down
10 changes: 5 additions & 5 deletions src/plist.c
Original file line number Diff line number Diff line change
Expand Up @@ -694,7 +694,7 @@ static Obj TypePlistWithKTNum (

Obj TypePlistNDense(Obj list)
{
if (IS_MUTABLE_PLAIN_OBJ(list))
if (IS_MUTABLE_OBJ(list))
return TYPE_LIST_NDENSE_MUTABLE;
else
return TYPE_LIST_NDENSE_IMMUTABLE;
Expand All @@ -704,31 +704,31 @@ Obj TypePlistNDense(Obj list)

Obj TypePlistDenseNHom(Obj list)
{
if (IS_MUTABLE_PLAIN_OBJ(list))
if (IS_MUTABLE_OBJ(list))
return TYPE_LIST_DENSE_NHOM_MUTABLE;
else
return TYPE_LIST_DENSE_NHOM_IMMUTABLE;
}

Obj TypePlistDenseNHomSSort(Obj list)
{
if (IS_MUTABLE_PLAIN_OBJ(list))
if (IS_MUTABLE_OBJ(list))
return TYPE_LIST_DENSE_NHOM_SSORT_MUTABLE;
else
return TYPE_LIST_DENSE_NHOM_SSORT_IMMUTABLE;
}

Obj TypePlistDenseNHomNSort(Obj list)
{
if (IS_MUTABLE_PLAIN_OBJ(list))
if (IS_MUTABLE_OBJ(list))
return TYPE_LIST_DENSE_NHOM_NSORT_MUTABLE;
else
return TYPE_LIST_DENSE_NHOM_NSORT_IMMUTABLE;
}

Obj TypePlistEmpty(Obj list)
{
if (IS_MUTABLE_PLAIN_OBJ(list))
if (IS_MUTABLE_OBJ(list))
return TYPE_LIST_EMPTY_MUTABLE;
else
return TYPE_LIST_EMPTY_IMMUTABLE;
Expand Down
2 changes: 1 addition & 1 deletion src/precord.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ Obj TYPE_PREC_IMMUTABLE;

Obj TypePRec(Obj prec)
{
return IS_MUTABLE_PLAIN_OBJ(prec) ? TYPE_PREC_MUTABLE : TYPE_PREC_IMMUTABLE;
return IS_MUTABLE_OBJ(prec) ? TYPE_PREC_MUTABLE : TYPE_PREC_IMMUTABLE;
}

/****************************************************************************
Expand Down
8 changes: 4 additions & 4 deletions src/range.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ Obj TYPE_RANGE_NSORT_MUTABLE;

Obj TypeRangeNSort(Obj list)
{
return IS_MUTABLE_PLAIN_OBJ(list) ? TYPE_RANGE_NSORT_MUTABLE
: TYPE_RANGE_NSORT_IMMUTABLE;
return IS_MUTABLE_OBJ(list) ? TYPE_RANGE_NSORT_MUTABLE
: TYPE_RANGE_NSORT_IMMUTABLE;
}


Expand All @@ -92,8 +92,8 @@ Obj TYPE_RANGE_SSORT_MUTABLE;

Obj TypeRangeSSort(Obj list)
{
return IS_MUTABLE_PLAIN_OBJ(list) ? TYPE_RANGE_SSORT_MUTABLE
: TYPE_RANGE_SSORT_IMMUTABLE;
return IS_MUTABLE_OBJ(list) ? TYPE_RANGE_SSORT_MUTABLE
: TYPE_RANGE_SSORT_IMMUTABLE;
}


Expand Down

0 comments on commit cbb5a73

Please sign in to comment.